Learn why WordPress’s WP-Cron triggering mechanism is meant to be replaced once WordPress is installed on a server.
What is WP-Cron?
“WP-Cron is how WordPress handles scheduling time-based tasks in WordPress.”Cron | Plugin Developer Handbook | WordPress Developer Resources
WP-Cron consists of a scheduling mechanism and triggering mechanism. This post is about disabling the WP-Cron triggering mechanism, while keep using the scheduling mechanism.
How does WP-Cron triggering mechanism work?
WP-Cron doesn’t actually do what it is supposed to do – run tasks at specific times. There is one more dependency WP-Cron relies on – a site activity, or in other words: a page load.
WP-Cron works by checking, on every page load, a list of scheduled tasks to see what needs to be run. Any tasks due to run will be called during that page load.
Note: WP-Cron does not run constantly as the system cron does; it is only triggered on page load.Cron | Plugin Developer Handbook | WordPress Developer Resources
So, out-of-the-box, WP-Cron only triggers when someone visits your site. This is, of course, not optimal for several reasons. For example, it puts extra strain on your server exactly at the moment when it is supposed to act its best – when you have a visitor on-site.
Why WP-Cron triggering mechanism works the way it does?
SiteGround phrases is clearly:
“Because WordPress has to work on all sort of different platforms, OS’s and configurations, it can’t rely that there will be a cronjob service on the server that can handle scheduled tasks.”How to Replace the WordPress Cron with a Real Cron Job Tutorial – SiteGround Knowledge Resources
Because WordPress is self-hosted, and because it must work out-of-the-box on as many environments as possible, WP-Cron triggering mechanism was created as a server-independent scheduled-tasks triggering solution.
Replace WP-Cron triggering mechanism with a server command
Once your WordPress is out of its box, the WP-Cron triggering workaround isn’t needed anymore. Once out of its box, the uncertainty about the environment your WordPress is going to live in is gone. At this point, it is best to replace the WP-Cron triggering mechanism with a server command, for a true time-based triggering and better performance and stability.
How to replace the WP-Cron triggering mechanism with a server command?
The answer is, of course, server-dependent. Most managed WordPress hosting companies have a dedicated guide. You can also contact your hosting support.