It’s very common to get this warning when you run speed tests for your WordPress website: Leverage browser caching Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network. Leverage browser caching for the following cacheable resources: Leverage browser caching for the following cacheable resources: http://www.google-analytics.com/analytics.js (2 hours) This error is referring to Google Analytics “analytics.js” file. And as it a 3rd party script, you cannot add expires headers to your .htaccess file or your Nginx configuration file. How to fix for your WordPress? Generally, you can fix this issue or any similar one by hosting the script locally on your server. But this particular script needs to be updated regularly when Google updates it. So you can host the script and run a cron job to update it. Fortunately, there is a lightweight plugin that does everything for you, just install, configure and forget about the Google Analytics Leverage Browser Caching warning. Complete Analytics Optimization Suite (CAOS) is a plugin that inserts the
Share This

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.