1

As a cron job does not run until a page load request comes, what will happen in case page-loaded is being served from cache by some caching plugin? Will WordPress still run a cron job that is scheduled to run in this case?

  • Depends on the cache, you should ask the plugin author. But if it's not loading WordPress, then probably not. You can set up a cron job on the server to hit wp-cron.php periodically though. – Jacob Peattie Feb 9 '18 at 0:33
  • Actually, I have to run a cron job from my plugin, so can't change plugin user's server config. – learning_13 Feb 9 '18 at 0:43
  • Then isn't this their problem? – Jacob Peattie Feb 9 '18 at 0:46
  • But as a plugin developer, I want to keep my data updated on a scheduled basis and can't be dependent on my plugin users cron configuration – learning_13 Feb 10 '18 at 18:42
2

It depends on the plugin and the cache method you are using. For example, as far as I remember, WP Super Cache offers two different cache methods:

  1. PHP Cache

  2. HTML Cache

Using the first method creates PHP cache files that still load WordPress's functions, but do not go through the whole loading process. If this is the case, it means that the PHP functions are executed, and your cron job will probably be processed. However, since the cron jobs are usually in the theme's functions.php file, and the PHP cache file is usually a PHP template cache, there is a chance that it won't trigger. You should have a closer look at the generated PHP cache files.

The second method simply creates status HTML files that are served directly. There is no PHP involved in this, so no cron job will be executed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.