{"id":22561,"date":"2022-02-18T17:30:06","date_gmt":"2022-02-18T16:30:06","guid":{"rendered":"https:\/\/f.technology\/blog\/preloading-in-wp-rocket\/"},"modified":"2022-02-18T17:30:06","modified_gmt":"2022-02-18T16:30:06","slug":"preloading-in-wp-rocket","status":"publish","type":"post","link":"https:\/\/f.technology\/en\/blog\/preloading-in-wp-rocket\/","title":{"rendered":"Preloading in WP Rocket"},"content":{"rendered":"<p>The <strong>Preloading<\/strong> section of <a href=\"https:\/\/wp-rocket.me\/it\/\" target=\"_blank\" rel=\"noopener\"><strong>WP Rocket<\/strong><\/a>, as the name suggests, is about the <strong>advance generation<\/strong> of different things. It is divided into 3 parts:<\/p>\n<ul>\n<li><strong><em>Cache<\/em><\/strong> preloading,<\/li>\n<li><strong><em>Link<\/em><\/strong> preloading,<\/li>\n<li><strong><em>DNS request<\/em><\/strong> preloading.<\/li>\n<\/ul>\n<p>For full documentation, see the <a href=\"https:\/\/docs.wp-rocket.me\/article\/8-how-the-cache-is-preloaded\" target=\"_blank\" rel=\"noopener\">official page<\/a>.<\/p>\n<p><em>As always, we recommend checking how <strong>WP Rocket<\/strong> integrates with your own <strong>server<\/strong>!<\/em> For example, with <a href=\"https:\/\/kinsta.com\/it\/strumenti-affidabili-per-wordpress\/wp-rocket\/\" target=\"_blank\" rel=\"noopener\">Kinsta<\/a>, even though WP Rocket is fully compatible, some features such as cache preloading or file minification (if Kinsta&#8217;s server-side minification is also enabled) are <a href=\"https:\/\/kinsta.com\/it\/blog\/wp-rocket\/\" target=\"_blank\" rel=\"noopener\">not recommended<\/a>.<\/p>\n<h2>Cache preloading<\/h2>\n<p><strong>Page <em>cache<\/em> preloading<\/strong> (<em>cache preload<\/em>) means that the cache is <strong>generated automatically<\/strong> by WP Rocket, regardless of what users do.<\/p>\n<p>As we saw in the <a href=\"https:\/\/f.technology\/en\/blog\/wp-rocket-basics\/\">previous article<\/a>, this is a <strong>recommended, default setting<\/strong> in WP Rocket.<\/p>\n<p>If preloading is turned off, each page needs at least one visit before it can be stored in the <em>cache<\/em>. As a result, the first visitor will always see it load more slowly.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-311 size-full\" src=\"https:\/\/f.technology\/wp-content\/uploads\/2022\/10\/precaricamento-cache.jpg\" alt=\"wp rocket preloading\" width=\"825\" height=\"503\" \/><\/p>\n<p>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 <em>links<\/em> it detects.<\/p>\n<p>When you enable the <strong>&#8220;Activate sitemap-based cache preloading&#8221;<\/strong> option, the sitemap is recognised and preloaded automatically. Sometimes you can also confirm the detected <em>sitemap<\/em>. This is the case with <strong>Yoast SEO<\/strong>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-313 size-full\" src=\"https:\/\/f.technology\/wp-content\/uploads\/2022\/10\/precaricamento-attiva.jpg\" alt=\"wp rocket preloading enabled\" width=\"540\" height=\"436\" \/><\/p>\n<p>Cache preloading happens globally:<\/p>\n<ul>\n<li>When the <strong><em>cache<\/em> expires<\/strong>,<\/li>\n<li>Every time the WP Rocket <strong>settings are saved<\/strong>,<\/li>\n<li>When you click the &#8220;<strong>Preload cache<\/strong>&#8221; button,<\/li>\n<li>When the <strong><em>plugin<\/em> is activated<\/strong>,<\/li>\n<li>When the <strong><em>cache<\/em> is cleared<\/strong>.<\/li>\n<li>In other cases determined by specific <em>servers<\/em> or by <em>plugins<\/em> such as<em> Varnish HTTP Purge<\/em>.<\/li>\n<\/ul>\n<p>For individual pages, it happens when <strong>content is published or updated<\/strong>.<\/p>\n<p>If <strong>separate <em>cache<\/em> for mobile devices<\/strong> is enabled, the mobile cache is also preloaded along with the <em>desktop<\/em> one:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-308 size-full\" src=\"https:\/\/f.technology\/wp-content\/uploads\/2022\/10\/06-cache-utente.jpg\" alt=\"user cache preloading\" width=\"1001\" height=\"599\" \/><\/p>\n<p>If <strong>WebP compatibility<\/strong> is enabled, WP Rocket will preload the WebP cache instead of the non-WebP one for the files involved.<\/p>\n<p>To check that cache preloading is <strong>working correctly<\/strong>, access the folder \/wp-content\/cache\/wp-rocket\/domainname\/ via FTP. It will contain all the cache files created. When you click &#8220;Preload cache&#8221;, the contents of the folder are updated.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-310\" src=\"https:\/\/f.technology\/wp-content\/uploads\/2022\/10\/precaricamento-funzionamento.jpg\" alt=\"Cache folders generated by WP Rocket preloading\" width=\"1138\" height=\"602\" srcset=\"https:\/\/f.technology\/wp-content\/uploads\/2022\/10\/precaricamento-funzionamento.jpg 1138w, https:\/\/f.technology\/wp-content\/uploads\/2022\/10\/precaricamento-funzionamento-300x159.jpg 300w, https:\/\/f.technology\/wp-content\/uploads\/2022\/10\/precaricamento-funzionamento-1024x542.jpg 1024w, https:\/\/f.technology\/wp-content\/uploads\/2022\/10\/precaricamento-funzionamento-768x406.jpg 768w\" sizes=\"auto, (max-width: 1138px) 100vw, 1138px\" \/><\/p>\n<p>With plugins such as <a href=\"https:\/\/wordpress.org\/plugins\/wp-cron-status-checker\/\" target=\"_blank\" rel=\"noopener\">WP-Cron Status Checker<\/a> or <a href=\"https:\/\/wordpress.org\/plugins\/wp-crontrol\/\" target=\"_blank\" rel=\"noopener\">WP Crontrol<\/a> you can also check the schedule of the preloading actions.<\/p>\n<p>The classic site health panel, found under <strong>Settings &#8211;&gt; Site Health<\/strong>, should not be underestimated either. From there we can check that no scheduled events have failed.<\/p>\n<p>If a cURL error 28 appears, it normally means the server is responding slowly. In that case, we suggest contacting your service provider.<\/p>\n<h3>More about <em>cache<\/em> preloading<\/h3>\n<p>Cache preloading <strong>never uses more than 90%<\/strong> of the available PHP memory. CPU usage should never be a problem.<\/p>\n<p>Sitemap-based preloading requires the <a href=\"https:\/\/www.php.net\/manual\/en\/book.simplexml.php\" target=\"_blank\" rel=\"noopener\">SimpleXML PHP extension<\/a> to be enabled <strong>on the<\/strong><em><strong> server<\/strong><\/em>.<\/p>\n<p>The default interval between URL crawls is 500ms. You can change it with a dedicated extension.<\/p>\n<p>You can schedule cache preloading by creating a dedicated <em>cron<\/em> job.<\/p>\n<h2>Link preloading<\/h2>\n<p>Only on <strong>Chrome<\/strong> and <strong>Chromium<\/strong> <em>browsers<\/em>!<\/p>\n<p><strong><em>Link<\/em> preloading<\/strong> improves the interaction time perceived by users as they browse the site.<\/p>\n<p>If the user hovers over a <em>link<\/em> for more than 100 ms, the HTML of the linked page is preloaded in the background.<\/p>\n<p>The option <strong>does not improve<\/strong> PageSpeed, Pingdom, GT Metrix scores and so on.<\/p>\n<p>The following are excluded automatically:<\/p>\n<ul>\n<li>Various admin URLs;<\/li>\n<li>URLs excluded from the WP Rocket <em>cache<\/em>;<\/li>\n<li>Images;<\/li>\n<li><em>Links<\/em> with query strings and anchors;<\/li>\n<li>External URLs.<\/li>\n<\/ul>\n<p>You can also <strong>exclude specific URLs manually<\/strong>, using the dedicated feature.<\/p>\n<p><em><strong>Warning! Files (including .docx) are not excluded from link preloading.<\/strong> This can cause errors, mainly because of the &#8220;\/&#8221; that is automatically appended.<\/em><br \/>\n<em>To avoid this, you can create rules with the <a href=\"https:\/\/raw.githubusercontent.com\/wp-media\/wp-rocket-helpers\/master\/cache\/wp-rocket-no-cache-urls-regexes\/wp-rocket-no-cache-urls-regexes.zip\" target=\"_blank\" rel=\"noopener\">WP Rocket | Regex Exclusions<\/a> extension.<\/em><\/p>\n<h2>DNS request preloading<\/h2>\n<p><strong>DNS request preloading<\/strong> (<em>DNS prefetch<\/em>) is particularly useful when the page contains third-party content.<\/p>\n<p>It makes the <strong>DNS resolution<\/strong> happen <strong>before the user interacts<\/strong> with the external content.<\/p>\n<p>Technically, <code>rel=\"dns-prefetch\"<\/code> is added to the header.<\/p>\n<p>For example, here a CDN, Google fonts, Pixel, Analytics and Tag Manager are handled:<\/p>\n<pre>&lt;link rel=\"<span class=\"nt\">dns-prefetch<\/span>\" href=\"<span class=\"na\">https:\/\/cdn.domain.com<\/span>\"&gt;\n&lt;link rel=\"<span class=\"nt\">dns-prefetch<\/span>\" href=\"<span class=\"na\">https:\/\/fonts.gstatic.com<\/span>\"&gt;\n&lt;link rel=\"<span class=\"nt\">dns-prefetch<\/span>\" href=\"<span class=\"na\">https:\/\/connect.facebook.net<\/span>\"&gt;\n&lt;link rel=\"<span class=\"nt\">dns-prefetch<\/span>\" href=\"<span class=\"na\">https:\/\/www.google-analytics.com<\/span>\"&gt;\n&lt;link rel=\"<span class=\"nt\">dns-prefetch<\/span>\" href=\"<span class=\"na\">https:\/\/www.googletagservices.com<\/span>\"&gt;<\/pre>\n<p>The improvement is hard to measure, but it is a <strong>recommended practice<\/strong>.<\/p>\n<p><strong>GT Metrix<\/strong> may suggest reducing DNS requests (<em>Reduce DNS Lookups<\/em>). DNS preloading <strong>does not make the suggestion go away<\/strong>: it does not eliminate the requests, it brings them forward. The only definitive solution remains <strong>removing third-party content<\/strong>.<\/p>\n<h2>Preload <em>fonts<\/em><\/h2>\n<p>By preloading <em>fonts<\/em> inside the <code>&lt;head&gt;<\/code> element, they are <strong>downloaded before they are discovered<\/strong> in the CSS.<\/p>\n<p>If the <em>fonts<\/em> are hosted on <strong>your domain or on the CDN<\/strong>, we recommend <strong>enabling the option<\/strong>. The feature cannot be used when they are hosted externally.<\/p>\n<p><em>If the &#8220;Remove Unused CSS&#8221; option is active under &#8220;File Optimization&#8221;, the preloaded fonts will be removed as well.<\/em><\/p>\n<h3>Which <em>fonts<\/em> should you preload?<\/h3>\n<p><strong>Google PageSpeed<\/strong> provides a dedicated &#8220;Preload Key Requests&#8221; item.<\/p>\n<p>It is useful to run the test bypassing WP Rocket with the <strong>\/?nowprocket<\/strong> parameter. The URL must also match the one provided by PageSpeed.<\/p>\n<p>Preload <strong>only the <em>fonts<\/em> that slow down page loading or perceived performance<\/strong>. Preloading can be <strong>counterproductive if it involves too many <em>fonts<\/em><\/strong>.<\/p>\n<p><em>Do not preload multiple formats! <strong>.woff2<\/strong> is normally enough.<\/em><\/p>\n<h3>PageSpeed warning<\/h3>\n<blockquote><p>Warnings: Lighthouse was unable to automatically check the `font-display` value for the origin<\/p><\/blockquote>\n<p>It is usually caused by preloading unused fonts. In these cases Chrome also shows a similar warning.<\/p>\n<h3>Preloading external fonts<\/h3>\n<p>This is not possible with WP Rocket.<\/p>\n<p>However, you can add a dedicated HTML line to the <code>&lt;head&gt;<\/code> section.<\/p>\n<pre><code>&lt;link rel=\"preload\" href=\"https:\/\/ESEMPIO.COM\/FONT.woff2\" as=\"font\" type=\"font\/woff2\" crossorigin&gt;<\/code><\/pre>\n<p>Enter the correct URL. The <em>type<\/em> attribute must identify the correct format.<\/p>\n<p>Once the code is in place, clear the WP Rocket cache.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":21353,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[65],"tags":[],"class_list":["post-22561","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-performance"],"acf":[],"_links":{"self":[{"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/posts\/22561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/comments?post=22561"}],"version-history":[{"count":0,"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/posts\/22561\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/media\/21353"}],"wp:attachment":[{"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/media?parent=22561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/categories?post=22561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/f.technology\/en\/wp-json\/wp\/v2\/tags?post=22561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}