Fix Leverage Browser Caching Warning for Google Analytics in WordPress

Spread the love
  • 1

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: (2 hours)

Leverage Browser Caching

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 Analytics tracking code into the header or footer, saves the analytics.js file locally and keeps it updated using wp_cron().

When you install Complete Analytics Optimization Suite (CAOS), go to Settings -> Optimize Analytics

Complete Analytics Optimization Suite

Enter in your Google Analytics Tracking ID and position for your tracking code. That’s all!

READ  10 Best WordPress Plugins for Small Business Sites

Now test your newly added tracking code by visiting your website in a new incognito window (Google Chrome) or Private window (Firefox) by going to your Google Analytics account -> Real Time -> Overview.

Please note:

You will need to deactivate other Google Analytics plugins or remove any other Google Analytics tracking codes you added to avoid inaccurate reporting.


Complete Analytics Optimization Suite (CAOS) is a cool plugin that helps you to add the Google Analytics code wherever you want (in the footer for example) and also get rid of the Leverage Browser Caching warning in your website speed tests.

(Visited 653 times, 1 visits today)
  • 1


I write about Multilingual WordPress, SEO, Website Performance. Also, I like answering WordPress question on Quora. When I have the time, I run online sessions to teach WordPress for my personal FB page fans!

facilisis consectetur efficitur. felis venenatis, libero diam quis id Praesent

Pin It on Pinterest

Do you find this interesting?

Share it with your friends!