Google PageSpeed Insights vs. Google Analytics

Validation tools such as the W3C Markup Validation Service or Google PageSpeed Insights are helpful to objectively evaluate the code and performance of a website. Especially Google influences a whole industry with concepts like above the fold - and also gives strict but useful guidelines in terms of image compression and caching. But it can happen that Google steps on its own feet.

Will the JavaScript tracking code

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', 'UA-12350231-1', 'auto');
  ga('send', 'pageview');

Integrated by Google Analytics on the website as officially described , Google complains about a lack of browser caching:

Google PageSpeed Insights vs. Google Analytics

Unfortunately, technically this can only be corrected by the host of the file, in this case Google itself, and it is only possible to fix it with the following workaround: First you bend the URL


to the own server to


and sets up a simple cron job via PHP, which downloads the latest .js file freshly to its own server every day:

file_put_contents("analytics.js", fopen("", 'r'));

Then you can fine-tune the caching so that PageSpeed ​​no longer criticizes the error:

Google PageSpeed Insights vs. Google Analytics