Preload cache
Overview of preloading
Despite the status of the Preload feature, WP Rocket will preload the homepage automatically after saving changes. Additionally, if the Separate cache files for mobile devices feature is enabled, the mobile version of the homepage will be preloaded as well.
When you enable “Activate Preloading”:
Your homepage and all the links found on it will be preloaded as follows:
- When you save changes to the WP Rocket settings (because the cache is cleared)
- When you click the Preload link from the admin toolbar, or on the WP Rocket dashboard
Cache Lifespan
The pages purged when the Cache Lifespan expires will be preloaded.
Updated content is preloaded
When you publish or update posts/pages/custom post types, WP Rocket automatically clears the cache for that specific content and any other content related to it (i.e. home, category, tag, pagination etc.). It also clears the cache for any URLs you've entered in the Always Purge URL(s) field.
This content and the related pages will be preloaded automatically after the cached files have been cleared.
Plugin activation
When you install WP Rocket for the first time, “Activate Preloading” is enabled by default and your homepage and links found on it will be preloaded immediately after activating the plugin, to ensure your site is fast right away.
Manual Cache Clear
When you manually clear the cache (from the admin toolbar or WP Rocket dashboard), only your homepage will be automatically preloaded. For a full preload, you must manually initiate that (from the admin toolbar or WP Rocket dashboard).
When you enable “sitemap-based cache preloading”:
Sitemaps generated by Yoast SEO, All-in-one-SEO, Rank Math SEO, SEOPress or The SEO Framework are detected and you can check the box to automatically use them.
If you don’t use one of those plugins, or want to specify sitemaps for preloading, enter the URLs in the "Sitemaps for preloading" text field.
These URLs will be preloaded after the homepage URLs are preloaded with the following triggers:
- When you click the Preload link from the admin toolbar, or on the WP Rocket dashboard
- Cache purge of some hosts (Pressidium, Savvii, WPEngine )
- After StudioPress Accelerator cache is cleared
- After the Vanish HTTP Purge plugin purges Varnish's cache
There is no duplication since any URL that already has a cache file will be skipped over.
Please note: By default, preload doesn't work for user cache or cookie-specific cache files.
For cookies, you can use a function to preload the value of a cookie instead of the regular cache.
Mobile Preloading
Preloading when WebP Compatibility is enabled
If you have enabled the WebP Compatibility option on the Media tab, WP Rocket will preload the WebP cache file instead of the non-WebP cache file.
Technical info
- The preload uses a background process which will never consume more than 90% of the available PHP memory. Therefore you shouldn’t encounter any high CPU issues.
- Sitemap preloading requires that the SimpleXML PHP extension is enabled on your server.
Troubleshooting
If you have any problems with preloading not working, please read this guide.
Stopping the preload
After a preload has been triggered, a notice will be displayed at the top of your screen. It contains a “stop preload” button if you want to halt the process:
Preload crawl interval
WP Rocket’s default interval for crawling URLs to be preloaded is 500 ms. That’s the time it will wait before moving from one URL to the next.
If you need to change the crawl interval, there’s a little extra plugin you can use for that purpose:
📥 Download (.zip): WP Rocket | Custom Preload Intervals
Developers: You can find the code for this plugin on GitHub.
Heads up! Remember to edit the value for the WPROCKETHELPERS_PRELOAD_INTERVAL_IN_SECONDS
constant; the default is 5
seconds.
Preloading at a specific time
If you want to make sure that a preload happens at a certain time every day, you can create a custom cron job through your webhosting control panel and launch one of these function at whatever time you want:
- To trigger homepage-based preloading:
run_rocket_bot()
- To trigger sitemap-based preloading:
run_rocket_sitemap_preload()
For further instructions, follow this guide on clearing the cache via cron job. Remember to change the function names to the ones above!