PageSpeed review and optimization

13,869

You can't (you do not control the Google servers, so you cannot set http headers on their behalf).

Moreover, you do not want to. Google already sets cache control headers for the gtm script:

Cache-Control:private, max-age=931

"Private" meaning that the http response is intended for a single user and should not cached in a way that makes it accessible to many users (i.e. a proxy server). Max age is the maximum age for the document before it expires and must be re-fetched from the server. You probably do not want to fiddle with those settings in any case, because usually you want any changes you are making to the tag container propagate to your users quickly.

Google pagespeed is more of a guideline in any case. Setting http headers is that kind of over-optimization that might make sense for certain high-traffic sites, but most sites have other, simpler problems that can and should be addressed first.

Share:
13,869
Ajay Parsana
Author by

Ajay Parsana

Updated on June 15, 2022

Comments

  • Ajay Parsana
    Ajay Parsana about 2 years

    I analysed my page speed using google pagespeed insight and got below suggestion. Can any one help me how I can implement it.

    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:
    http://www.googletagmanager.com/gtm.js?id=GTM-TVSKP6 (16.2 minutes)