Preloading in WP Rocket

The Preloading section of WP Rocket, as the name suggests, is about the advance generation of different things. It is divided into 3 parts: Cache preloading, Link preloading, DNS request preloading. For full documentation, see the official page. As always, we recommend checking how WP Rocket integrates with your own server! For example, with Kinsta,…

Author

Franco Farnedi

Published

18 February 2022

Reading time

5 minutes

Category

Performance

The Preloading section of WP Rocket, as the name suggests, is about the advance generation of different things. It is divided into 3 parts:

  • Cache preloading,
  • Link preloading,
  • DNS request preloading.

For full documentation, see the official page.

As always, we recommend checking how WP Rocket integrates with your own server! For example, with Kinsta, even though WP Rocket is fully compatible, some features such as cache preloading or file minification (if Kinsta’s server-side minification is also enabled) are not recommended.

Cache preloading

Page cache preloading (cache preload) means that the cache is generated automatically by WP Rocket, regardless of what users do.

As we saw in the previous article, this is a recommended, default setting in WP Rocket.

If preloading is turned off, each page needs at least one visit before it can be stored in the cache. As a result, the first visitor will always see it load more slowly.

wp rocket preloading

If enabled without further options, WP Rocket will generate the cache starting from the home page and then carry on by itself, following all the links it detects.

When you enable the “Activate sitemap-based cache preloading” option, the sitemap is recognised and preloaded automatically. Sometimes you can also confirm the detected sitemap. This is the case with Yoast SEO:

wp rocket preloading enabled

Cache preloading happens globally:

  • When the cache expires,
  • Every time the WP Rocket settings are saved,
  • When you click the “Preload cache” button,
  • When the plugin is activated,
  • When the cache is cleared.
  • In other cases determined by specific servers or by plugins such as Varnish HTTP Purge.

For individual pages, it happens when content is published or updated.

If separate cache for mobile devices is enabled, the mobile cache is also preloaded along with the desktop one:

user cache preloading

If WebP compatibility is enabled, WP Rocket will preload the WebP cache instead of the non-WebP one for the files involved.

To check that cache preloading is working correctly, access the folder /wp-content/cache/wp-rocket/domainname/ via FTP. It will contain all the cache files created. When you click “Preload cache”, the contents of the folder are updated.

Cache folders generated by WP Rocket preloading

With plugins such as WP-Cron Status Checker or WP Crontrol you can also check the schedule of the preloading actions.

The classic site health panel, found under Settings –> Site Health, should not be underestimated either. From there we can check that no scheduled events have failed.

If a cURL error 28 appears, it normally means the server is responding slowly. In that case, we suggest contacting your service provider.

More about cache preloading

Cache preloading never uses more than 90% of the available PHP memory. CPU usage should never be a problem.

Sitemap-based preloading requires the SimpleXML PHP extension to be enabled on the server.

The default interval between URL crawls is 500ms. You can change it with a dedicated extension.

You can schedule cache preloading by creating a dedicated cron job.

Link preloading

Only on Chrome and Chromium browsers!

Link preloading improves the interaction time perceived by users as they browse the site.

If the user hovers over a link for more than 100 ms, the HTML of the linked page is preloaded in the background.

The option does not improve PageSpeed, Pingdom, GT Metrix scores and so on.

The following are excluded automatically:

  • Various admin URLs;
  • URLs excluded from the WP Rocket cache;
  • Images;
  • Links with query strings and anchors;
  • External URLs.

You can also exclude specific URLs manually, using the dedicated feature.

Warning! Files (including .docx) are not excluded from link preloading. This can cause errors, mainly because of the “/” that is automatically appended.
To avoid this, you can create rules with the WP Rocket | Regex Exclusions extension.

DNS request preloading

DNS request preloading (DNS prefetch) is particularly useful when the page contains third-party content.

It makes the DNS resolution happen before the user interacts with the external content.

Technically, rel="dns-prefetch" is added to the header.

For example, here a CDN, Google fonts, Pixel, Analytics and Tag Manager are handled:

<link rel="dns-prefetch" href="https://cdn.domain.com">
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
<link rel="dns-prefetch" href="https://connect.facebook.net">
<link rel="dns-prefetch" href="https://www.google-analytics.com">
<link rel="dns-prefetch" href="https://www.googletagservices.com">

The improvement is hard to measure, but it is a recommended practice.

GT Metrix may suggest reducing DNS requests (Reduce DNS Lookups). DNS preloading does not make the suggestion go away: it does not eliminate the requests, it brings them forward. The only definitive solution remains removing third-party content.

Preload fonts

By preloading fonts inside the <head> element, they are downloaded before they are discovered in the CSS.

If the fonts are hosted on your domain or on the CDN, we recommend enabling the option. The feature cannot be used when they are hosted externally.

If the “Remove Unused CSS” option is active under “File Optimization”, the preloaded fonts will be removed as well.

Which fonts should you preload?

Google PageSpeed provides a dedicated “Preload Key Requests” item.

It is useful to run the test bypassing WP Rocket with the /?nowprocket parameter. The URL must also match the one provided by PageSpeed.

Preload only the fonts that slow down page loading or perceived performance. Preloading can be counterproductive if it involves too many fonts.

Do not preload multiple formats! .woff2 is normally enough.

PageSpeed warning

Warnings: Lighthouse was unable to automatically check the `font-display` value for the origin

It is usually caused by preloading unused fonts. In these cases Chrome also shows a similar warning.

Preloading external fonts

This is not possible with WP Rocket.

However, you can add a dedicated HTML line to the <head> section.

<link rel="preload" href="https://ESEMPIO.COM/FONT.woff2" as="font" type="font/woff2" crossorigin>

Enter the correct URL. The type attribute must identify the correct format.

Once the code is in place, clear the WP Rocket cache.

Share the article

Available for work

Stay in touch

Have a new project to start, or just want to know more about what we do? Our team helps you find the solution that best fits your needs.

Contact us