Preload cache

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.

Feature overview

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.

preload interface

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 preload

Full cache preloading will run on the following URLs:

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_domain function is called.

Partial preload

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, etc.)
  • URLs in the Always Purge URL(s) box.
  • Pages purged when the Cache Lifespan expires.

Basic requirements

The Preload relies on the following basic requirements:

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:

  1. Access your WordPress installation path via (S)FTP or File Manager
  2. Go to the cache folder, at /wp-content/cache/wp-rocket/yourdomain.com/
  3. Click on Clear cache and preload from the admin bar
  4. Refresh the folder, it should be emptied
  5. Refresh once more, and the cache files should begin to appear, inside their own slug-specific folders.

    Example:  /wp-content/cache/wp-rocket/yourdomain.com/product/index-https.html.

Preload when page caching is disabled

Even when page caching is disabled, enabling Preload is useful to trigger the other optimizations, including Minify CSS files, Remove Unused CSS, Delay JavaScript execution, etc. 

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 modified value in the wp_wpr_rocket_cache table, with the oldest modified being preloaded first.

    Since the  modified value changes as pages are edited and new pages are posted, the order in which URLs are preloaded changes constantly.

    When a post is edited, it won’t be preloaded in priority versus an existing queue of URLs to preload, instead, the edited post will be sent to the back of the queue.

You can use the rocket_sitemap_preload_list and 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.

URLs automatically excluded from the Preload

From WP Rocket 3.12.6, the Preload is disabled for paginated pages. This means, URLs that contain /page/, or whatever the WordPress pagination base is, will not be preloaded.

As a clarification note, the paginated URLs can still be cached if they're visited, but they won't be added to the preloading queue.

If you wish to change this behavior, and preload paginated pages, you can add the following snippet as explained here:

function enable_preload_for_pagination( $regexes ){
		global $wp_rewrite;
		$pagination_regex = "/$wp_rewrite->pagination_base/\d+";
		$exluded_urls = [		
			$pagination_regex,
		];
		$regexes = array_diff( $regexes, $exluded_urls);
		return $regexes;
	}
add_filter( 'rocket_preload_exclude_urls', 'enable_preload_for_pagination');

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.

Technical info

  • 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.
  • The rocket_preload_job_parse_sitemap hook is used to detect the sitemaps to be preloaded.
  • The rocket_preload_process_pending cron event checks the preload status of the URLs. It will trigger the preload for 45 URLs per minute.
    • The rocket_preload_job_preload_url action 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 wp_wpr_rocket_cache table.
  • The rocket_preload_clean_rows_time_event cron 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.1 for mobile.

Troubleshooting

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: 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!

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.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.