How is the cache preloaded?


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 the Cache Lifespan expires
  • When you click the Preload link from the admin toolbar, or on the WP Rocket dashboard

Updated content is preloaded

Additionally, 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.). This content and the related pages will be preloaded automatically.

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.

When you enable “sitemap-based cache preloading”:

Sitemaps generated by Yoast SEO, All-in-one-SEO, 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, according to the same triggers: 

  • When you change the WP Rocket settings (because the cache is cleared)
  • When the Cache Lifespan expires
  • When you click the Preload link from the admin toolbar, or on the WP Rocket dashboard

There is no duplication since any URL that already has a cache file will be skipped over. 

NOTE: Preload doesn't work for separate mobile or cookie-specific cache files.

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 in version 3 and above, 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!

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.

Troubleshooting

If you have any problems with preloading not working,  please read this guide.

Prefetch DNS requests

If you have third-party content on your website (e.g fonts loaded from Google, or a video from YouTube), you may want to add its origin domain to the  Prefetch DNS Requests option. This can give your loading time a minor boost, since DNS resolution will already have been processed when the external resources get requested.

Add the origin host with relative protocol (double slash, no http:) like so: