The Preload Cache feature emulates a visit to your site's pages to generate cache files. Since the feature is enabled by default on plugin installation, there's no need to wait until a real visitor accesses the pages before starting to serve cache files, therefore, your pages are fast from the first visit.
By default, despite the status of the Preload feature, WP Rocket will preload the homepage automatically upon plugin activation and 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 first enable Preload, you'll see the following admin notice:
WP Rocket: The preload service is now active. After the initial preload it will continue to cache all your pages whenever they are purged. No further action is needed.
The Preload is an ongoing process, attached to the cache clearing. This means the pages will be preloaded every time their cache was cleared.
At the same time, any URL that already has a cache file - its cache wasn't cleared - will be skipped over, making the process optimal.
In this sense, WP Rocket can trigger full or partial preload after the cache is cleared, as follows:
Full cache preloading will run on the following URLs:
- URLs in sitemaps generated by plugins with automatic compatibility
- URLs found on WordPress default sitemap - In case no third-party sitemap is detected.
- URLs found on the homepage - In case WordPress default sitemap isn't available.
- URLs that aren’t included in a sitemap and that received a visit
And, the preloading will run in the following scenarios:
- When you save changes to WP Rocket settings that affect the front-end (because the cache is cleared).
- When you click the Clear and preload cache button in the admin toolbar, or on the WP Rocket dashboard.
- Whenever the
rocket_clean_domainfunction is called.
Partial cache preloading takes effect when WP Rocket automatically clears the cache for the following URLs:
- Published or updated URLs, such as posts/pages/custom post types.
- Including any other content related to it (i.e. home, category, tag, pagination etc.)
- URLs in the Always Purge URL(s) box.
- Pages purged when the Cache Lifespan expires.
The Preload relies on the following basic requirements:
- WP-Cron or a real server-side cron job must be able to run, the latter is strongly recommended for the Preload to run properly.
- The SimpleXML PHP extension needs to be enabled on your server.
How to check if Preload is working
When enabled, the Preload will create the cache files. In order to see if the Preload is working, please follow these steps:
- Access your WordPress installation path via (S)FTP or File Manager
- Go to the cache folder, at /wp-content/cache/wp-rocket/yourdomain.com/
- Click on Clear cache and preload from the admin bar
- Refresh the folder, it should be emptied
- Refresh once more, and the cache files should begin to appear, inside their own slug-specific folders.
Preload when page caching is disabled
This is the case for some hosting providers such as Kinsta, WP Engine, DreamPress, Flywheel. See the full list of hosting providers where page caching is disabled in this article.
Preload for cookies and User Cache
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.
Preload based on SEO plugin's sitemaps
WP Rocket's Preload has automatic compatibility with most common SEO plugins. The URLs found in their sitemaps will be included in the preload process. This is the list of compatible plugins:
If none of the above plugins are detected, the preloading will work based on WordPress default sitemap.
Customize Preload sitemaps and priority
By default, Preload will:
- Work on URLs found in the compatible sitemaps.
- Run on URLs according to their
modifiedvalue. Since the
modifiedvalue changes as pages are edited and new pages are posted, the order in which URLs are preloaded changes constantly.
You can use the
rocket_preload_order filters to customize the above behavior. For more information, please check the following article:
Customize Preload sitemaps and priority.
Preload and Mobile Cache
If you have enabled the Separate cache files for mobile devices option under the Mobile Cache feature, mobile-specific cache files will also be generated by the Preload in addition to desktop-specific cache files.
Preload and WebP Compatibility Add-on
If you have enabled the WebP Compatibility Add-on, WP Rocket will preload the WebP cache file instead of the non-WebP cache file.
How to exclude URLs from being preloaded
You can exclude pages and groups of pages from being preloaded, but still cached, using the Exclude URLs box.
You can find more information here: exclude URLs from being preloaded.
How to stop the preload process
If you need to stop the preload, deactivate the Preload option. The current batch of URLs will finish, and then it will stop completely.
- The Preload uses a background process, limited to using up to 90% of the available PHP memory.
- The full process relies on WP Cron or a server-side cron, and Action Scheduler.
rocket_preload_job_parse_sitemaphook is used to detect the sitemaps to be preloaded.
rocket_preload_process_pendingcron event checks the preload status of the URLs. It will trigger the preload for 45 URLs per minute.
rocket_preload_job_preload_urlaction event will track and handle the Preload status of each URL.
- The tracking of the status of the URLs is done in the database, in the
rocket_preload_clean_rows_time_eventcron event is used to delete old rows, its frequency is once per week.
- The Preload works with two user agents:
WP Rocket/Preload, for the desktop version, and
Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1for mobile.
- If the CPU usage is high when Preload is enabled, please check this article.
- If the preloading is slow or not working, please read this guide.
Preload in WP Rocket versions prior to 3.12
Heads up! The following is obsolete information, which is only relevant to WP Rocket 3.11.5 and older.
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.
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).
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:
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
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:
- To trigger sitemap-based preloading:
For further instructions, follow this guide on clearing the cache via cron job. Remember to change the function names to the ones above!
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:
Heads up! Remember to edit the value for the
WPROCKETHELPERS_PRELOAD_INTERVAL_IN_SECONDS constant; the default is