Try Now

Running Cache Lifespan at specific time

Cache lifespan can be set to run at a specific time but there is a catch here which we will describe and help you find a way to make sure it runs without any issue.

How Cache lifespan works?

Cache lifespan of SpeedyCache is dependent on WP Cron, which is a Cron functionality of WordPress. But this is not an actual Cron. A cron is a utility which is used to schedule jobs which is independent of any user visiting the website and will work until the server is running.

Whereas WP Cron is dependent on users visiting the website, which means if no user comes to your website, the WP Cron will not work, hence none of the functionality dependent on the WP Cron will work.

Lets take an example of running cache lifespan at 2:00 AM, so if no user visits the site at 2:00 AM then the WP-Cron will not work hence no cache will be deleted.

How to make sure Cache lifespan works?

To make sure that cache lifespan works, you will need to use the real CronJob. For that you will need to have access to your Control Panel.

Given that you have access to the Cron Job from your control panel, you will need to use the below command as the command for Cron Job and make it run every 5 minutes or as per your need.

wget -q -O - https://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

Once you have saved the cron settings now you need to do one more thing, which is to add a line in wp-config.php

define('DISABLE_WP_CRON', true);

You need to add this constant in the wp-config.php, what it does is it will not initiate WP-Cron when the user visits and will only work based on the CronJob you have set, which will make sure this works every time whether users are coming to your website or not.

If you face any issue doing it, reach out to our support at support@speedycace.com

    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list