admin管理员组文章数量:1306001
Hi I'm using to test my wordpress site speed and I have an F for Leverage browser caching, it says:
The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
.js
+Sans
+Sans:300,400,700
What else do I need to add to my .htaccess file? I already have this:
EXPIRES CACHING
ExpiresActive On
ExpiresByType image/jpg "access 1 week"
ExpiresByType image/jpeg "access 1 week"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 week"
ExpiresByType text/css "access 2 month"
ExpiresByType application/pdf "access 2 year"
ExpiresByType text/x-javascript "access 2 month"
ExpiresByType application/x-shockwave-flash "access 2 month"
ExpiresByType image/x-icon "access 2 year"
ExpiresDefault "access 2 days"
ExpiresByType video/mp4 "access 2 year"
EXPIRES CACHING
Hi I'm using https://tools.pingdom. to test my wordpress site speed and I have an F for Leverage browser caching, it says:
The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
https://ssl.google-analytics./ga.js
https://fonts.googleapis./css?family=Droid+Sans
https://fonts.googleapis./css?family=Lora
https://fonts.googleapis./css?family=Merriweather+Sans:300,400,700
What else do I need to add to my .htaccess file? I already have this:
EXPIRES CACHING
ExpiresActive On
ExpiresByType image/jpg "access 1 week"
ExpiresByType image/jpeg "access 1 week"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 week"
ExpiresByType text/css "access 2 month"
ExpiresByType application/pdf "access 2 year"
ExpiresByType text/x-javascript "access 2 month"
ExpiresByType application/x-shockwave-flash "access 2 month"
ExpiresByType image/x-icon "access 2 year"
ExpiresDefault "access 2 days"
ExpiresByType video/mp4 "access 2 year"
EXPIRES CACHING
Share Improve this question asked Nov 1, 2016 at 18:56 Charles XavierCharles Xavier 1,0453 gold badges15 silver badges34 bronze badges1 Answer
Reset to default 5Only way to do this would be to download the stylesheets/fonts and add them to your server, since you can't affect Google's 1 day expiration headers.
Open your https://fonts.googleapis./css?family= links and get the individual fonts, for example: https://fonts.gstatic./s/droidsans/v6/s-BiyweUPV0v-yRb-cjciPk_vArhqVIZ0nv9q090hN8.woff2
Download that and save it to your server. Now you can use the same styles as in the google stylesheets but inside your own css file. Make sure to change the fonts.gstatic. link to the file on your server.
If you don't want to do that then a better way to handle your requests is like this:
<link rel="dns-prefetch" href="//fonts.googleapis.">
<link rel="dns-prefetch" href="//ssl.google-analytics.">
<link rel="stylesheet" href="//fonts.googleapis./css?family=Droid+Sans|Lora|Merriweather+Sans:300,400,700">
<script src="//ssl.google-analytics./ga.js" async></script>
EDIT 12/2: The reason you wouldn't want to do this is because Google may update the font, however, fonts don't really get updated that often.
版权声明:本文标题:javascript - The following cacheable resources have a short freshness lifetime - Google fonts - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741802490a2398307.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论