【问题标题】:Leverage browser caching - PageSpeed Insights issue [duplicate]利用浏览器缓存 - PageSpeed Insights 问题 [重复]
【发布时间】:2015-11-11 19:06:52
【问题描述】:

我收到此错误:

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.google-analytics.com/analytics.js (2 hours)

这是我的谷歌分析 js 代码:

<script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

        ga('create', 'UA-35812981-4', 'auto');
        ga('send', 'pageview');
    </script>

stackoverflow 上关于这条消息的问题很少,他们的回答对我不起作用。我怎样才能摆脱这个消息?我的分数是 99/100,这是唯一的一个。你能帮我解决这个问题吗?

【问题讨论】:

    标签: .htaccess caching google-analytics


    【解决方案1】:

    一个可能的解决方案是使用this service。它提供了analytics.js 的缓存副本,该副本具有更长的时间。您只需将分析链接更改为以下链接:http://www.schedule-analytics.com/analytics.js

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-04
      • 2014-07-08
      • 2020-09-10
      • 2015-09-06
      相关资源
      最近更新 更多