PageSpeed Insights 99/100 because of Google Analytics - How can I cache GA?

前端 未结 20 1768
無奈伤痛
無奈伤痛 2020-11-29 15:10

I\'m on a quest to reach 100/100 on PageSpeed and i\'m almost there. I\'m trying to find a good solution to cache Google Analytics.

Here is the message I get:

20条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 15:36

    For Nginx:

    location ~ /analytics.js {
            proxy_pass https://www.google-analytics.com;
            expires 31536000s;
            proxy_set_header Pragma "public";
            proxy_set_header Cache-Control "max-age=31536000, public";
        }
    

    Then change path https://www.google-analytics.com/analytics.js to https://yoursite.com/analytics.js

提交回复
热议问题