{"id":3916226,"date":"2021-11-29T13:55:57","date_gmt":"2021-11-29T12:55:57","guid":{"rendered":"https:\/\/wp-rocket.me\/?post_type=core_web_vitals_hub&#038;p=3916226"},"modified":"2023-04-12T16:00:55","modified_gmt":"2023-04-12T14:00:55","slug":"serve-static-assets-with-an-efficient-cache-policy","status":"publish","type":"core_web_vitals_hub","link":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/","title":{"rendered":"How to Serve Assets With an Efficient Cache Policy on WordPress"},"content":{"rendered":"<p>Do you want to know how to easily fix the leverage browser caching warning in your WordPress site? You are at the right place.&nbsp;<a href=\"https:\/\/pagespeed.web.dev\/report?url=https%3A%2F%2Fwp-rocket.me%2F&amp;hl=en\">Google PageSpeed Insights<\/a> is a useful tool for measuring website performance, but it&#8217;s possible to be intimidated by some of its suggestions. The &#8220;Leverage browser caching&#8221; recommendation has recently been changed to \u201cServe static assets with an efficient cache policy\u201d.<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"500\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png\" alt=\"How to Fix Leverage Browser Caching on WordPress\" class=\"wp-image-3882242\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro-310x195.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro-768x480.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure><p>How to fix this warning for your WordPress site?&nbsp;<\/p><p>In this article, we will share several optimization techniques you can follow, and we\u2019ll also explain what \u201cLeverage Browser Caching\u201d is. Finally, a performance test will also be conducted<em> before<\/em> and <em>after<\/em> using WP Rocket to see how easy it is to improve your Google PageSpeed score and address the browser caching issue.<\/p><h2 class=\"wp-block-heading\">What Browser Caching is and How it Works<\/h2><h3 class=\"wp-block-heading\">Browser Caching Explained in Plain English&nbsp;<\/h3><p>Implementing browser caching will help to reduce the server load by reducing the number of requests per page. <strong>&nbsp;<\/strong>Caching allows recent web pages to be stored temporarily in the web browser of your visitors.&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Browser-caching-explained-Source-WP-Rocket.png\" alt=\"Browser caching explained - Source: WP Rocket\" class=\"wp-image-3882248\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Browser-caching-explained-Source-WP-Rocket.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Browser-caching-explained-Source-WP-Rocket-260x195.png 260w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Browser-caching-explained-Source-WP-Rocket-768x576.png 768w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Browser-caching-explained-Source-WP-Rocket-80x60.png 80w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Browser-caching-explained-Source-WP-Rocket-120x90.png 120w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Browser caching explained &#8211; Source: WP Rocket<br><\/figcaption><\/figure><p>Speeding up your web page loading can be accomplished with browser caching, which stores the frequently accessed resources on local memory for faster access. All the requests are running locally rather than being sent over a network connection. As a result, your HTML pages and images are rendered faster, reducing bandwidth usage and server load.&nbsp;<\/p><p>To activate caching in the browser, we will be looking at both \u201cExpires\u201d and \u201c<a href=\"https:\/\/wp-rocket.me\/blog\/cache-control-http-headers\/\">Cache-Control<\/a>\u201d headers:<\/p><figure class=\"wp-block-table\"><table><tbody><tr><td><strong>\u201cExpires\u201d header: <\/strong>a basic way to enable caching on the browser and specify a time duration after which the resource will be deleted.<br><br>\u201c<strong>Cache-Control\u201d header: <\/strong>it\u2019s<strong> <\/strong>more detailed and gives fine-grained options to control the caching behavior of the browser.&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure><h3 class=\"wp-block-heading\">How to Check if Browser Caching is Enabled on Your Site<\/h3><p>To check if browser caching is enabled on your WordPress site, go to Google PageSpeed Insights and run the audit with the URL of your site. If you see the \u201cServe static assets with an efficient cache policy\u201d warning, then that means you are not using a cache.<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1244\" height=\"585\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-PSI.png\" alt=\"Checking browser caching - Source: PSI\" class=\"wp-image-3882261\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-PSI.png 1244w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-PSI-310x146.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-PSI-768x361.png 768w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-PSI-128x60.png 128w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-PSI-191x90.png 191w\" sizes=\"(max-width: 1244px) 100vw, 1244px\" \/><figcaption class=\"wp-element-caption\">Checking browser caching &#8211; Source: PSI<br><\/figcaption><\/figure><p><br><\/p><p>Similarly, you can use <a href=\"https:\/\/gtmetrix.com\/\">GTmetrix<\/a> to check if the browser caching is activated:&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"390\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-GTmetrix.png\" alt=\"Checking browser caching - Source: GTmetrix\" class=\"wp-image-3882269\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-GTmetrix.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-GTmetrix-310x151.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Checking-browser-caching-Source-GTmetrix-768x374.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure><p><br>Finally, you can also use the \u201cNetwork\u201d tab in Chrome\u2019s developer tools. Simply select the page that you want to analyze and check the \u201cHeaders\u201d tab:&nbsp;&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"474\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Cache-Control-Header-on-Chrome.png\" alt=\"\u201cCache-Control\u201d Header on Chrome\" class=\"wp-image-3882277\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Cache-Control-Header-on-Chrome.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Cache-Control-Header-on-Chrome-310x184.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Cache-Control-Header-on-Chrome-768x455.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">\u201cCache-Control\u201d Header on Chrome<br><\/figcaption><\/figure><h2 class=\"wp-block-heading\">What Does Serve Assets With an Efficient Cache Policy Mean on PageSpeed Insights?<\/h2><p>\u201cLeverage Browser Caching\u201d was a recommendation in version 4 of the PageSpeed Insights API, which was shut down in May 2019. Since Version 5, real-world data from the Chrome User Experience Report and lab data are coming from Lighthouse, which replaced the diagnostic with the \u201cServe assets with an efficient cache policy\u201d warning.&nbsp;<\/p><figure class=\"wp-block-table\"><table><tbody><tr><td>\u201cLeverage Browser Caching\u201d (2019) \u2192 \u201cServe assets with an efficient cache policy\u201d (2021)<\/td><\/tr><\/tbody><\/table><\/figure><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"376\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Lighthouse-issue-Source-new-PSI-diagnostics-section-.png\" alt=\"Lighthouse issue - Source: new PSI diagnostics section \" class=\"wp-image-3882286\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Lighthouse-issue-Source-new-PSI-diagnostics-section-.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Lighthouse-issue-Source-new-PSI-diagnostics-section--310x146.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Lighthouse-issue-Source-new-PSI-diagnostics-section--768x361.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Lighthouse issue &#8211; Source: new PSI diagnostics section&nbsp;<br><\/figcaption><\/figure><h3 class=\"wp-block-heading\">Why Do You See the \u201cServe Static Assets With An Efficient Cache Policy\u201d Issue?&nbsp;<\/h3><p>Leverage browser caching means that you should specify how long web browsers should keep your files stored locally &#8211; on the visitor\u2019s browser. There are two headers involved in browser caching, namely \u201c<a href=\"https:\/\/wp-rocket.me\/blog\/cache-control-http-headers\/\">Cache-Control<\/a>\u201d and \u201cExpires\u201d. If you see the Lighthouse&#8217;s issue, that means that both headers are missing or that their expiration period is too short.&nbsp;<\/p><figure class=\"wp-block-table\"><table><tbody><tr><td>Lighthouse flags all static resources that aren&#8217;t cached according to the following criteria:<br><br>&#8211; The resource is a font, image, media file, script, or stylesheet<br><br>&#8211; The resource has a 200, 203, or 206 <a href=\"https:\/\/developer.mozilla.org\/docs\/Web\/HTTP\/Status\">HTTP status code<\/a><br><br>&#8211; The resource doesn&#8217;t have an explicit no-cache policy<\/td><\/tr><\/tbody><\/table><\/figure><p>There are three main reasons why Lighthouse flags your WordPress site with that issue, namely:<br><\/p><h4 class=\"wp-block-heading\">1. Leverage Browser Caching for Google Analytics and Tag Manager<\/h4><p>Google Analytics is the most popular tool when it comes to statistics of your WordPress site. However, the code in the \u201canalytics.js\u201d file goes back and forth to Google\u2019s server, so the browser treats it every time as a new external resource. Google has set a 2 hours cache policy that is too short for Lighthouse, which triggers the warning.<\/p><h4 class=\"wp-block-heading\">2. Leverage Browser Caching for Other Third-Party and External Scripts&nbsp;<\/h4><p>Sometimes, you may use plugins that require adding some additional scripts from another server, such as a YouTube video or your Instagram feed. Some plugin authors have set up a cache policy on their scripts.<\/p><h4 class=\"wp-block-heading\">3. Nginx Servers Where The Expiry Headers Are Not Properly Set&nbsp;<\/h4><p>Nginx is the king of the servers to deliver content quickly. The thing is, Nginx does not use a .htaccess file, so you need to add the configuration for both headers in the main server block if you want Nginx to read them. If you don\u2019t do that, Nginx (and Lighthouse) will not detect the expiry data properly.&nbsp;<\/p><p>To leverage browser caching on WordPress also means an improvement in the loading speed of your website because the files don\u2019t need to be \u201cre-downloaded\u201d. To make things easier, we have put together a list of techniques you can use to fix leverage browser caching warnings (with and without a WordPress plugin).<\/p><div id=\"om-nyrydv5iync8zrrulm5i-holder\"><\/div>\n\t<script>(function (d, u, ac) {\n\t\t\tvar s = d.createElement('script')\n\t\t\ts.type = 'text\/javascript'\n\t\t\ts.src = 'https:\/\/a.omappapi.com\/app\/js\/api.min.js'\n\t\t\ts.async = true\n\t\t\ts.dataset.user = u\n\t\t\ts.dataset.campaign = ac\n\t\t\td.getElementsByTagName('head')[0].appendChild(s)\n\t\t})(document, 20440, 'nyrydv5iync8zrrulm5i')<\/script><h2 class=\"wp-block-heading\">How to Serve Assets With an Efficient Cache Policy with a Plugin&nbsp;<\/h2><p>The easiest way to leverage browser caching is to do it with a WordPress plugin such as:&nbsp;<\/p><ul class=\"wp-block-list\"><li><a href=\"https:\/\/wp-rocket.me\/features\/\">WP Rocket<\/a> is one of the <a href=\"https:\/\/wp-rocket.me\/best-wordpress-caching-plugin\/\">best caching plugins for WordPress<\/a>, allowing you to leverage browser caching in WordPress.<br><\/li><\/ul><p>WP Rocket sets the <strong>optimal expiration lengths<\/strong> for certain files by adding some rules via the .htaccess file.<br><br>Note: WP Rocket will work automatically on Nginx servers, but you can add some <a href=\"https:\/\/github.com\/SatelliteWP\/rocket-nginx\">extra configuration from Github<\/a>. It will add headers to cache CSS, JS, and images to leverage the browser&#8217;s cache by reducing requests to your web server.<\/p><figure class=\"wp-block-table\"><table><tbody><tr><td>\ud83d\ude80 WP Rocket automatically applies the necessary \u201cExpires\u201d header rules in the .htaccess file&nbsp;<\/td><\/tr><\/tbody><\/table><\/figure><p>WP Rocket also comes with the Delay JavaScript option that optimizes the loading of 3rd party scripts. We can compare it as Lazy Loading but for JavaScript. <a href=\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/reduce-javascript-execution-time\/#delay-js-remove-unused-js\">WP Rocket will delay any JS scripts<\/a> until there is user interaction with the web page:<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"366\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Delay-JS-execution-Source-WP-Rocket-.png\" alt=\"Delay-JS-execution-Source-WP-Rocket-\" class=\"wp-image-3882293\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Delay-JS-execution-Source-WP-Rocket-.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Delay-JS-execution-Source-WP-Rocket--310x142.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Delay-JS-execution-Source-WP-Rocket--768x351.png 768w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Delay-JS-execution-Source-WP-Rocket--131x60.png 131w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Delay-JS-execution-Source-WP-Rocket--197x90.png 197w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Delay JS execution &#8211; Source: WP Rocket&nbsp;<br><\/figcaption><\/figure><p>Another benefit of WP Rocket is <a href=\"https:\/\/docs.wp-rocket.me\/article\/1560-delay-javascript-execution-compatibility-exclusions\">the list of compatibility exclusions<\/a> to spare you the hassle of figuring out what should or shouldn&#8217;t be hosted.&nbsp;<\/p><ul class=\"wp-block-list\"><li>The <a href=\"https:\/\/wordpress.org\/plugins\/leverage-browser-caching\/\">Leverage Browser Caching<\/a> plugin &#8211; limited to Apache\/LiteSpeed servers where the browser cache can be controlled by using the .htaccess file (<em>it does not work with Nginx servers<\/em>). There are no options that need to be activated. It works immediately upon the activation of the plugin. It simply adds the browser caching code inside the .htaccess file.&nbsp;&nbsp;<\/li><\/ul><ul class=\"wp-block-list\"><li><a href=\"https:\/\/wordpress.org\/plugins\/host-analyticsjs-local\/\">Complete Analysis Optimization Suite<\/a> (CAOS) &#8211; fixes GA leverage browser caching warning in WordPress by hosting the analytics.js\/gtag.js file locally. By default, Google sets the expiration at 2 hours, and the plugin simply overrides this setting. <em>Note that CAOS won\u2019t work with any other GA\u2019s related plugin.<\/em><\/li><\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"401\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Choosing-where-to-display-the-tracking-code-Source-CAOS-dashboard.png\" alt=\"Choosing where to display the tracking code - Source: CAOS dashboard\" class=\"wp-image-3882300\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Choosing-where-to-display-the-tracking-code-Source-CAOS-dashboard.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Choosing-where-to-display-the-tracking-code-Source-CAOS-dashboard-310x155.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Choosing-where-to-display-the-tracking-code-Source-CAOS-dashboard-768x385.png 768w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Choosing-where-to-display-the-tracking-code-Source-CAOS-dashboard-120x60.png 120w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Choosing-where-to-display-the-tracking-code-Source-CAOS-dashboard-180x90.png 180w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Choosing where to display the tracking code &#8211; Source: CAOS dashboard<br><\/figcaption><\/figure><h2 class=\"wp-block-heading\">How to Serve Assets With an Efficient Cache Policy Without a Plugin<\/h2><p>There are a few techniques you can use to set up your static asset cache manually. The first thing you need to do is figure out which web server is used for serving files on the website, then follow these instructions accordingly:&nbsp;<\/p><h3 class=\"wp-block-heading\">1. Add \u201cCache-Control\u201d and \u201cExpires\u201d Headers in Nginx&nbsp;<\/h3><p>First, find your server block usually located at \/etc\/nginx\/site-enabled\/default.<\/p><p>Then, add the following code snippets with the number of days until expiration next to the \u201cexpires\u201d line:&nbsp;<br><strong><br>\u201cCache-Control\u201d header in Nginx:<\/strong><\/p><pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">location ~* \\.(png|jpg|jpeg|gif)$ {\n    expires 365d;\n    add_header Cache-Control \"public, no-transform\";\n}\n\nlocation ~* \\.(js|css|pdf|html|swf)$ {\n    expires 30d;\n    add_header Cache-Control \"public, no-transform\";\n}\n<\/code><\/pre><p><strong>\u201cExpire\u201d header in Nginx:<\/strong><\/p><pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">location ~* \\.(jpg|jpeg|gif|png)$ {\n    expires 365d;\n}\n\nlocation ~* \\.(pdf|css|html|js|swf)$ {\n    expires 30d;\n}\n<\/code><\/pre><h3 class=\"wp-block-heading\">2. Add Cache-Control Header in Apache<\/h3><p>For Apache servers, simply put the following code in your .htaccess file:&nbsp;<\/p><pre class=\"wp-block-code\"><code lang=\"php\" class=\"language-php\">\n# Expires headers (for better cache control)\r\n&lt;IfModule mod_expires.c>\r\nExpiresActive on\r\n    ExpiresDefault                              \"access plus 1 month\"\r\n    # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)\r\n    ExpiresByType text\/cache-manifest           \"access plus 0 seconds\"\r\n    # Your document html\r\n    ExpiresByType text\/html                     \"access plus 0 seconds\"\r\n    # Data\r\n    ExpiresByType text\/xml                      \"access plus 0 seconds\"\r\n    ExpiresByType application\/xml               \"access plus 0 seconds\"\r\n    ExpiresByType application\/json              \"access plus 0 seconds\"\r\n    # Feed\r\n    ExpiresByType application\/rss+xml           \"access plus 1 hour\"\r\n    ExpiresByType application\/atom+xml          \"access plus 1 hour\"\r\n    # Favicon (cannot be renamed)\r\n    ExpiresByType image\/x-icon                  \"access plus 1 week\"\r\n    # Media: images, video, audio\r\n    ExpiresByType image\/gif                     \"access plus 4 months\"\r\n    ExpiresByType image\/png                     \"access plus 4 months\"\r\n    ExpiresByType image\/jpeg                    \"access plus 4 months\"\r\n    ExpiresByType image\/webp                    \"access plus 4 months\"\r\n    ExpiresByType video\/ogg                     \"access plus 4 months\"\r\n    ExpiresByType audio\/ogg                     \"access plus 4 months\"\r\n    ExpiresByType video\/mp4                     \"access plus 4 months\"\r\n    ExpiresByType video\/webm                    \"access plus 4 months\"\r\n    ExpiresByType image\/avif                    \"access plus 4 months\"\r\n    ExpiresByType image\/avif-sequence           \"access plus 4 months\"\r\n    # HTC files  (css3pie)\r\n    ExpiresByType text\/x-component              \"access plus 1 month\"\r\n    # Webfonts\r\n    ExpiresByType font\/ttf    \"access plus 4 months\"\r\n    ExpiresByType font\/otf    \"access plus 4 months\"\r\n    ExpiresByType font\/woff   \"access plus 4 months\"\r\n    ExpiresByType font\/woff2  \"access plus 4 months\"\r\n    ExpiresByType image\/svg+xml                 \"access plus 4 months\"\r\n    ExpiresByType application\/vnd.ms-fontobject \"access plus 1 month\"\r\n    # CSS and JavaScript\r\n    ExpiresByType text\/css                      \"access plus 1 year\"\r\n    ExpiresByType application\/javascript        \"access plus 1 year\"\r\n&lt;\/IfModule>\n<\/code><\/pre><p>You can find those code snippets directly on <a href=\"https:\/\/github.com\/GoogleChrome\/lighthouse\/blob\/master\/lighthouse-core\/audits\/byte-efficiency\/uses-long-cache-ttl.js\">Github<\/a> or <a href=\"https:\/\/gtmetrix.com\/serve-static-assets-with-an-efficient-cache-policy.html\">GTMetrix<\/a>.<\/p><h3 class=\"wp-block-heading\">3. Self-host 3rd Party Scripts When Possible<\/h3><p>Third-party scripts are the calls made on an external server instead of yours. The most common external scripts include advertising tags, YouTube videos, Google Maps, and web fonts.&nbsp;<\/p><p>You can increase the performance of your website by hosting third-party scripts on your server. Hosting them helps you reduce DNS lookups, round trip times and improves <a href=\"https:\/\/wp-rocket.me\/blog\/cache-control-http-headers\/\">HTTP caching headers <\/a>with advanced features like HTTP\/2 server push.<br><br><em>Important note<\/em>: Not all 3rd party scripts can be self-hosted, and some might even break if they are. Self-hosted is recommended only if any critical scripts depend upon it (e.g., jQuery). It&#8217;s acceptable not to have all 3rd party scripts with a proper browser cache policy; the performance gain is negligible when it&#8217;s just a few of them.<\/p><h3 class=\"wp-block-heading\">4. Reduce Third-Party Scripts&nbsp;<\/h3><p>You may be in control of your Google PageSpeed Insights score, but third-party scripts on the page can cause problems as we don&#8217;t know what their caching policies are like. Also, all these elements have to be downloaded from different servers, which can cause performance issues, as your server needs to connect to multiple servers to download them.&nbsp;<br><br>While you can\u2019t have full control over those scripts, you can still minimize their effects on your WordPress site by applying those four optimization techniques:<\/p><ol class=\"wp-block-list\"><li>Minify\/Combine CSS and Minify\/Combine JS &#8211; the files hosted on external domains will be processed and hosted on your own domain. Use a tool like <a href=\"https:\/\/minifycode.com\/\">minifycode.com<\/a> to minify your code.&nbsp;<\/li><\/ol><ol class=\"wp-block-list\" start=\"2\"><li>Delay the execution of external JavaScript &#8211; to reduce its negative performance impact. Use the <a href=\"https:\/\/javascript.info\/script-async-defer\">defer and async attribute<\/a> to delay JS.<\/li>\n\n<li>Optimize Google Fonts &#8211; it does improve the performance (but does not host fonts locally).&nbsp;<\/li>\n\n<li><a href=\"https:\/\/web.dev\/lazy-loading-images\/\">LazyLoad your images<\/a> and videos &#8211; this will improve the performance of externally hosted images and videos. You can find more about the <a href=\"https:\/\/wp-rocket.me\/blog\/lazyloading\/\">lazy loading script in our dedicated guide<\/a>.&nbsp;<\/li><\/ol><figure class=\"wp-block-table\"><table><tbody><tr><td>Do you want to apply those four techniques in a couple of clicks instead?<br>Let <a href=\"https:\/\/wp-rocket.me\/features\/\">WP Rocket<\/a> do the job for you!<\/td><\/tr><\/tbody><\/table><\/figure><h3 class=\"wp-block-heading\">5. Use Cloudflare browser cache Time To Live (TTL)&nbsp;<\/h3><p>Cloudflare offers a CDN with 250 servers distributed internationally. The free service caches content for its users, while paid customers can customize how long their data is served up in the global cache. By default, Cloudflare honors the expiration date set in an Expires header and Cache-Control settings, but you can also specify a different time range if desired. When the TTL expires, the browser will request the asset again.&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"534\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Caching-a-website-with-Cloudflare-Source-Cloudflare.png\" alt=\"Caching a website with Cloudflare  - Source: Cloudflare\" class=\"wp-image-3882341\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Caching-a-website-with-Cloudflare-Source-Cloudflare.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Caching-a-website-with-Cloudflare-Source-Cloudflare-292x195.png 292w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Caching-a-website-with-Cloudflare-Source-Cloudflare-768x513.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Caching a website with Cloudflare&nbsp; &#8211; Source: <a href=\"https:\/\/www.cloudflare.com\/fr-fr\/learning\/cdn\/what-is-caching\/\">Cloudflare<\/a><br><\/figcaption><\/figure><h2 class=\"wp-block-heading\">How to Easily Serve Assets With an Efficient Cache Policy With WP Rocket<\/h2><p>Thanks to <a href=\"https:\/\/wp-rocket.me\/features\/\">WP Rocket<\/a>, it\u2019s very easy to get rid of the browser caching warning on Google PageSpeed Insights. The plugin sets the <strong>best<\/strong> expiration lengths for each file by adding automatic rules via the .htaccess file.&nbsp;<\/p><p>Let\u2019s see it in action.&nbsp;<\/p><p>I\u2019ve created a web page on WordPress containing some text modules, images, and third-party content (a YouTube video and my Instagram feed).&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"787\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Test-site-on-WordPress-.png\" alt=\"Test site on WordPress \" class=\"wp-image-3882349\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Test-site-on-WordPress-.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Test-site-on-WordPress--198x195.png 198w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Test-site-on-WordPress--768x756.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure><p><strong><br><\/strong><\/p><p>We will run the two following scenarios:<\/p><p><strong><a href=\"#scenario-1\">Scenario #1<\/a> &#8211;<\/strong> Performance score and analysis of the diagnostics and opportunities sections (no WP Rocket).<\/p><p><strong><a href=\"#scenario-2\">Scenario #2<\/a> &#8211;<\/strong> Performance score and analysis of the diagnostics sections (\ud83d\ude80 with WP Rocket).<\/p><p><strong>Performance tool used &#8211;<\/strong> I will use<strong> <\/strong>Google PageSpeed Insights (Lighthouse) to measure our speed and performance.&nbsp;<\/p><p><strong>Device &#8211; <\/strong>I\u2019ll present results on mobile.<\/p><p>Let\u2019s dive in!<\/p><h3 class=\"wp-block-heading\" id=\"scenario-1\">Scenario #1 &#8211; Performance score and analysis of the diagnostics and opportunities sections (no WP Rocket)<\/h3><p>My overall performance score is 52\/100 on mobile, and one of my Core Web Vitals is red (<a href=\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/improve-largest-contentful-paint\/\">Largest Contentful Paint<\/a>). Other metrics such as <a href=\"https:\/\/wp-rocket.me\/lighthouse-performance-score-wordpress\/improve-speed-index\/\">Speed Index<\/a>, <a href=\"https:\/\/wp-rocket.me\/lighthouse-performance-score-wordpress\/improve-time-to-interactive\/\">Time to Interactive<\/a>, <a href=\"https:\/\/wp-rocket.me\/lighthouse-performance-score-wordpress\/improve-first-contentful-paint\/\">First Contentful Paint<\/a>, and <a href=\"https:\/\/wp-rocket.me\/lighthouse-performance-score-wordpress\/reduce-total-blocking-time\/\">Total Blocking Time<\/a> are red.&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"487\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/My-performance-on-mobile-without-WP-Rocket-Source-PSI.png\" alt=\"My performance on mobile without WP Rocket - Source: PSI\" class=\"wp-image-3882357\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/My-performance-on-mobile-without-WP-Rocket-Source-PSI.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/My-performance-on-mobile-without-WP-Rocket-Source-PSI-310x189.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/My-performance-on-mobile-without-WP-Rocket-Source-PSI-768x468.png 768w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/My-performance-on-mobile-without-WP-Rocket-Source-PSI-99x60.png 99w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/My-performance-on-mobile-without-WP-Rocket-Source-PSI-148x90.png 148w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">My performance on mobile without WP Rocket &#8211; Source: PSI<br><\/figcaption><\/figure><p>In the diagnostics section below, we can see that Lighthouse is making a few recommendations to improve my performance score:<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"385\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Diagnostics-section-Source-PSI.png\" alt=\"Diagnostics section - Source: PSI\" class=\"wp-image-3882366\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Diagnostics-section-Source-PSI.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Diagnostics-section-Source-PSI-310x149.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Diagnostics-section-Source-PSI-768x370.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Diagnostics section &#8211; Source: PSI<br><\/figcaption><\/figure><p>I can see three familiar recommendations:&nbsp;<\/p><ul class=\"wp-block-list\"><li>Serve static assets with an efficient cache policy <em>(previously knowns as \u201cLeverage Browser Caching\u201d )<\/em><\/li><\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"333\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Serve-static-assets-with-an-efficient-cache-policy-Source-PSI.png\" alt=\"Serve static assets with an efficient cache policy - Source: PSI\" class=\"wp-image-3882372\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Serve-static-assets-with-an-efficient-cache-policy-Source-PSI.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Serve-static-assets-with-an-efficient-cache-policy-Source-PSI-310x129.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Serve-static-assets-with-an-efficient-cache-policy-Source-PSI-768x320.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Serve static assets with an efficient cache policy &#8211; Source: PSI<br><\/figcaption><\/figure><ul class=\"wp-block-list\"><li>Reduce the impact of third-party code&nbsp;<\/li><\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"257\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Reduce-the-impact-of-third-party-code-Source-PSI.png\" alt=\"Reduce the impact of third-party code - Source: PSI\" class=\"wp-image-3882379\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Reduce-the-impact-of-third-party-code-Source-PSI.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Reduce-the-impact-of-third-party-code-Source-PSI-310x100.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Reduce-the-impact-of-third-party-code-Source-PSI-768x247.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Reduce the impact of third-party code &#8211; Source: PSI<br><\/figcaption><\/figure><ul class=\"wp-block-list\"><li>Some third-party resources can be lazy-loaded with a facade<\/li><\/ul><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"198\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Some-third-party-resources-can-be-lazy-loaded-with-a-facade-Source-PSI.png\" alt=\"Some third-party resources can be lazy loaded with a facade - Source: PSI\" class=\"wp-image-3882390\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Some-third-party-resources-can-be-lazy-loaded-with-a-facade-Source-PSI.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Some-third-party-resources-can-be-lazy-loaded-with-a-facade-Source-PSI-310x77.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Some-third-party-resources-can-be-lazy-loaded-with-a-facade-Source-PSI-768x190.png 768w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Some-third-party-resources-can-be-lazy-loaded-with-a-facade-Source-PSI-190x47.png 190w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Some-third-party-resources-can-be-lazy-loaded-with-a-facade-Source-PSI-364x90.png 364w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Some third-party resources can be lazy-loaded with a facade &#8211; Source: PSI<br><\/figcaption><\/figure><p>In the opportunities section, Lighthouse also tells me to enable text compression, optimize my JS\/CSS code, and <a href=\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/defer-offscreen-images\/\">defer offscreen images<\/a> to optimize my performance.&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"366\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Opportunities-section-without-WP-Rocket-Source-PSI.png\" alt=\"Opportunities section without WP Rocket - Source: PSI\n\" class=\"wp-image-3882398\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Opportunities-section-without-WP-Rocket-Source-PSI.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Opportunities-section-without-WP-Rocket-Source-PSI-310x142.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Opportunities-section-without-WP-Rocket-Source-PSI-768x351.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure><p>Now let\u2019s activate WP Rocket to see if those performance-related warnings disappear.&nbsp;<\/p><h3 class=\"wp-block-heading\" id=\"scenario-2\"><strong>S<\/strong>cenario #2 &#8211; Performance score and analysis of the diagnostics section (\ud83d\ude80 with WP Rocket)<\/h3><p>My performance is much better when WP Rocket is activated. My score on mobile went from 52\/100 to 92\/100, and none of my metrics are in the red anymore:<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"479\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Performance-score-on-mobile-with-WP-Rocket-Source-PSI-.png\" alt=\"Performance score on mobile with WP Rocket - Source: PSI\" class=\"wp-image-3882408\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Performance-score-on-mobile-with-WP-Rocket-Source-PSI-.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Performance-score-on-mobile-with-WP-Rocket-Source-PSI--310x186.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Performance-score-on-mobile-with-WP-Rocket-Source-PSI--768x460.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Performance score on mobile with WP Rocket &#8211; Source: PSI<br><\/figcaption><\/figure><p><strong>And last but not least: all my PSI issues got solved just by enabling WP Rocket! <\/strong>The following warnings,&nbsp; \u201cuses an efficient cache policy\u201d <em>(previously known as leverage browser caching) <\/em>\u201cMinimize third-party usage\u201d and \u201cLazy load third-party resources with facade\u201d are now in the passed audits section:&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"548\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/WP-Rocket-fixing-the-leverage-browser-caching-issue-Source-PSI.png\" alt=\"WP Rocket fixing the leverage browser caching issue - Source: PSI\" class=\"wp-image-3882420\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/WP-Rocket-fixing-the-leverage-browser-caching-issue-Source-PSI.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/WP-Rocket-fixing-the-leverage-browser-caching-issue-Source-PSI-285x195.png 285w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/WP-Rocket-fixing-the-leverage-browser-caching-issue-Source-PSI-768x526.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">WP Rocket fixing the leverage browser caching issue &#8211; Source: PSI<br><\/figcaption><\/figure><p>As a side note, WP Rocket also fixed other performance issues. Upon activation, I managed to minify my CSS\/JS, lazy load my images, <a href=\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/remove-unused-css\/\">reduce my unused CSS<\/a> and JS files, delay the non-critical JS and enable text compression.&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"658\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Main-WP-Rocket-features-.png\" alt=\"Main WP Rocket features \" class=\"wp-image-3882426\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Main-WP-Rocket-features-.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Main-WP-Rocket-features--237x195.png 237w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Main-WP-Rocket-features--768x632.png 768w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Main-WP-Rocket-features--73x60.png 73w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Main-WP-Rocket-features--109x90.png 109w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Main WP Rocket features&nbsp;<br><\/figcaption><\/figure><h2 class=\"wp-block-heading\">Wrapping Up&nbsp;<\/h2><p>Caching is crucial to ensure that your webpage loads fast for returning users. We\u2019ve seen some manual techniques you can use to fix the leverage browser caching issue on WordPress, mainly by adding lines of code to your .htaccess file. But if you want to save time, let WP Rocket complete all the optimization process for you.&nbsp;<\/p><p>So you can automatically go from this:&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"121\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-without-WP-Rocket.png\" alt=\"Issues without WP Rocket\" class=\"wp-image-3882433\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-without-WP-Rocket.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-without-WP-Rocket-310x47.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-without-WP-Rocket-768x116.png 768w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-without-WP-Rocket-190x29.png 190w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-without-WP-Rocket-595x90.png 595w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Issues without WP Rocket<br><\/figcaption><\/figure><p>To this:&nbsp;<\/p><figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"125\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-fixed-by-WP-Rocket.png\" alt=\"Issues fixed by WP Rocket\" class=\"wp-image-3882441\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-fixed-by-WP-Rocket.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-fixed-by-WP-Rocket-310x48.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/Issues-fixed-by-WP-Rocket-768x120.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption class=\"wp-element-caption\">Issues fixed by WP Rocket<br><\/figcaption><\/figure><p>WP Rocket will apply 80% of web performance best practices upon its activation, as seen in our previous section\u2019s performance audit. <\/p><p><a href=\"https:\/\/wp-rocket.me\/features\/\">Give it a try today<\/a>, and if you don\u2019t see any improvements, you get a refund within 14 days of your purchase. See? You don\u2019t take any risk! Simply activate WP Rocket and speed up your site right away!<\/p>","protected":false},"excerpt":{"rendered":"<p>Serving static assets with an efficient cache policy (former Leverage browser caching) plays a key role in WordPress. By following our performance recommendations you&#8217;ll improve your website performance in no time.<\/p>\n","protected":false},"template":"","core_web_vitals":[132],"class_list":["post-3916226","core_web_vitals_hub","type-core_web_vitals_hub","status-publish","hentry","core_web_vitals-improve-largest-contentful-paint"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Serve Assets With an Efficient Cache Policy on WordPress<\/title>\n<meta name=\"description\" content=\"Serving static assets with an efficient cache policy plays a key role in WordPress. By following these techniques you&#039;ll improve your website performance in no time.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Serve Assets With an Efficient Cache Policy on WordPress\" \/>\n<meta property=\"og:description\" content=\"Serving static assets with an efficient cache policy plays a key role in WordPress. By following these techniques you&#039;ll improve your website performance in no time.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Rocket\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-12T14:00:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@wp_rocket\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/\",\"url\":\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/\",\"name\":\"How to Serve Assets With an Efficient Cache Policy on WordPress\",\"isPartOf\":{\"@id\":\"https:\/\/wp-rocket.me\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png\",\"datePublished\":\"2021-11-29T12:55:57+00:00\",\"dateModified\":\"2023-04-12T14:00:55+00:00\",\"description\":\"Serving static assets with an efficient cache policy plays a key role in WordPress. By following these techniques you'll improve your website performance in no time.\",\"breadcrumb\":{\"@id\":\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#primaryimage\",\"url\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png\",\"contentUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png\",\"width\":800,\"height\":500,\"caption\":\"How to Fix Leverage Browser Caching on WordPress\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wp-rocket.me\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Core Web Vitals\",\"item\":\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Largest Contentful Paint\",\"item\":\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/improve-largest-contentful-paint\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to Serve Assets With an Efficient Cache Policy on WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wp-rocket.me\/#website\",\"url\":\"https:\/\/wp-rocket.me\/\",\"name\":\"WP Rocket\",\"description\":\"Plugin d&#039;optimisation de sites WordPress\",\"publisher\":{\"@id\":\"https:\/\/wp-rocket.me\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wp-rocket.me\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/wp-rocket.me\/#organization\",\"name\":\"WP Rocket\",\"url\":\"https:\/\/wp-rocket.me\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png\",\"contentUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png\",\"width\":150,\"height\":41,\"caption\":\"WP Rocket\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829\",\"https:\/\/x.com\/wp_rocket\",\"https:\/\/www.youtube.com\/channel\/UC1ozThXHd1IWIZ5wkshgp_Q\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Serve Assets With an Efficient Cache Policy on WordPress","description":"Serving static assets with an efficient cache policy plays a key role in WordPress. By following these techniques you'll improve your website performance in no time.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/","og_locale":"en_US","og_type":"article","og_title":"How to Serve Assets With an Efficient Cache Policy on WordPress","og_description":"Serving static assets with an efficient cache policy plays a key role in WordPress. By following these techniques you'll improve your website performance in no time.","og_url":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/","og_site_name":"WP Rocket","article_publisher":"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829","article_modified_time":"2023-04-12T14:00:55+00:00","og_image":[{"url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png"}],"twitter_card":"summary_large_image","twitter_site":"@wp_rocket","twitter_misc":{"Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/","url":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/","name":"How to Serve Assets With an Efficient Cache Policy on WordPress","isPartOf":{"@id":"https:\/\/wp-rocket.me\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#primaryimage"},"image":{"@id":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#primaryimage"},"thumbnailUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png","datePublished":"2021-11-29T12:55:57+00:00","dateModified":"2023-04-12T14:00:55+00:00","description":"Serving static assets with an efficient cache policy plays a key role in WordPress. By following these techniques you'll improve your website performance in no time.","breadcrumb":{"@id":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#primaryimage","url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png","contentUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/2021\/11\/How-to-Fix-Leverage-Browser-Caching-on-WordPress-intro.png","width":800,"height":500,"caption":"How to Fix Leverage Browser Caching on WordPress"},{"@type":"BreadcrumbList","@id":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/serve-static-assets-with-an-efficient-cache-policy\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wp-rocket.me"},{"@type":"ListItem","position":2,"name":"Core Web Vitals","item":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/"},{"@type":"ListItem","position":3,"name":"Largest Contentful Paint","item":"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/improve-largest-contentful-paint\/"},{"@type":"ListItem","position":4,"name":"How to Serve Assets With an Efficient Cache Policy on WordPress"}]},{"@type":"WebSite","@id":"https:\/\/wp-rocket.me\/#website","url":"https:\/\/wp-rocket.me\/","name":"WP Rocket","description":"Plugin d&#039;optimisation de sites WordPress","publisher":{"@id":"https:\/\/wp-rocket.me\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wp-rocket.me\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wp-rocket.me\/#organization","name":"WP Rocket","url":"https:\/\/wp-rocket.me\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/","url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png","contentUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png","width":150,"height":41,"caption":"WP Rocket"},"image":{"@id":"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829","https:\/\/x.com\/wp_rocket","https:\/\/www.youtube.com\/channel\/UC1ozThXHd1IWIZ5wkshgp_Q"]}]}},"_links":{"self":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/core_web_vitals_hub\/3916226"}],"collection":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/core_web_vitals_hub"}],"about":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/types\/core_web_vitals_hub"}],"wp:attachment":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/media?parent=3916226"}],"wp:term":[{"taxonomy":"core_web_vitals","embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/core_web_vitals?post=3916226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}