新增ExpiresByType为.htaccess,但PageSpeed​​见解还是说我应该"利用浏览器缓存" [英] Added ExpiresByType to .htaccess but PageSpeed Insights still states that I should "Leverage Browser Caching"

查看:375
本文介绍了新增ExpiresByType为.htaccess,但PageSpeed​​见解还是说我应该"利用浏览器缓存"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了以下code到我的.htaccess,但PageSpeed​​洞察仍显示了利用浏览器缓存的建议。

 < IfModule mod_expires.c>
ExpiresActive上
ExpiresDefault访问权限1月
 ExpiresByType图像/ X-ICO的访问权限1年
 ExpiresByType图像/ JPG访问14种日
 ExpiresByType为image / jpeg访问14种日
 ExpiresByType图像/ GIF访问14种日
 ExpiresByType text / html的访问2天
 ExpiresByType文本/ CSS访问2日
 ExpiresByType图像/ PNG访问1个月
 ExpiresByType文/ X-的javascript访问权限1月
 ExpiresByType应用程序/ JavaScript的访问权限1月
 ExpiresByType应用程序/ x-j​​avascript的访问权限1月
< / IfModule>
 

尽管如此,PageSpeed​​洞察仍然指出,我应该利用浏览器缓存为以下内容:

  http://assets.pinterest.com/images/PinExt.png(60秒)
https://assets.pinterest.com/js/pinit.js(60秒)
http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=60(5分钟)
http://1.gravatar.com/avatar/572ef8c1916a898c441306a0f75f883e?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G (5分钟)
http://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=60(5分钟)
http://cdn.api.twitter.com/1/urls/count.json?url=http%3A%2F%2Fwww.mbaadmissiongurus.com%2Fsample-mba-sop&callback=twttr.receiveCount (13.6分钟)
http://widgets.pinterest.com/v1/urls/count.json?url=http%3A%2F%2Fwww.mbaadmissiongurus.com%2Fsample-mba-sop&ref=http%3A%2F%2Fwww.mbaadmissiongurus.com%2Fsample-mba-sop&source=6&callback=PIN_1378214653068.f.callback[0] (14.8分钟)
https://connect.facebook.net/en_US/all.js(20分钟)
https://apis.google.com/js/plusone.js(30分钟)
https://platform.twitter.com/widgets.js(30分钟)
http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js(60分钟)
http://pagead2.googlesyndication.com/pagead/osd.js(60分钟)
https://oauth.googleusercontent.com/gadgets/js/core:rpc:shindig.random:shindig.sha1.js?c=2(60分钟)
https://platform.stumbleupon.com/1/widgets.js(2小时)
https://platform.linkedin.com/in.js(3小时)
https://s2.googleusercontent.com/s2/favicons?domain_url=ExportControls.com/e-seminars(8小时)
https://s2.googleusercontent.com/s2/favicons?domain_url=healthcare-tataaig.com/Health-Cover(8小时)
https://s2.googleusercontent.com/s2/favicons?domain_url=worldeducationfair.com(8小时)
https://s2.googleusercontent.com/s2/favicons?domain_url=www.Dulux.in(8小时)
https://s2.googleusercontent.com/s2/favicons?domain_url=www.asianpaintshomesolutions.com(8小时)
https://s2.googleusercontent.com/s2/favicons?domain_url=www.principalretirementindia.com(8小时)
 

解决方案

所有的上市资源,似乎是外在的。不能添加/修改页眉和/或缓存行为,一般的外部资源,因此没有什么可以到这一点。

只要确保你的控制之下的所有资源(从服务器(S)和CDN或即将)正确地利用缓存。

I have added the following code to my .htaccess but PageSpeed Insights still shows a Leverage Browser Caching suggestion.

<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access 1 month"
 ExpiresByType image/x-ico "access 1 year"
 ExpiresByType image/jpg "access 14 days"
 ExpiresByType image/jpeg "access 14 days"
 ExpiresByType image/gif "access 14 days"
 ExpiresByType text/html "access 2 day"
 ExpiresByType text/css "access 2 days"
 ExpiresByType image/png "access 1month"
 ExpiresByType text/x-javascript "access 1 month"  
 ExpiresByType application/javascript "access 1 month"  
 ExpiresByType application/x-javascript "access 1 month"
</IfModule>

Despite the above, PageSpeed Insights still states that I should leverage browser caching for the following:

http://assets.pinterest.com/images/PinExt.png (60 seconds)
https://assets.pinterest.com/js/pinit.js (60 seconds)
http://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=60 (5 minutes)
http://1.gravatar.com/avatar/572ef8c1916a898c441306a0f75f883e?s=60&d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D60&r=G (5 minutes)
http://1.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=60 (5 minutes)
http://cdn.api.twitter.com/1/urls/count.json?url=http%3A%2F%2Fwww.mbaadmissiongurus.com%2Fsample-mba-sop&callback=twttr.receiveCount (13.6 minutes)
http://widgets.pinterest.com/v1/urls/count.json?url=http%3A%2F%2Fwww.mbaadmissiongurus.com%2Fsample-mba-sop&ref=http%3A%2F%2Fwww.mbaadmissiongurus.com%2Fsample-mba-sop&source=6&callback=PIN_1378214653068.f.callback[0] (14.8 minutes)
https://connect.facebook.net/en_US/all.js (20 minutes)
https://apis.google.com/js/plusone.js (30 minutes)
https://platform.twitter.com/widgets.js (30 minutes)
http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js (60 minutes)
http://pagead2.googlesyndication.com/pagead/osd.js (60 minutes)
https://oauth.googleusercontent.com/gadgets/js/core:rpc:shindig.random:shindig.sha1.js?c=2 (60 minutes)
https://platform.stumbleupon.com/1/widgets.js (2 hours)
https://platform.linkedin.com/in.js (3 hours)
https://s2.googleusercontent.com/s2/favicons?domain_url=ExportControls.com/e-seminars (8 hours)
https://s2.googleusercontent.com/s2/favicons?domain_url=healthcare-tataaig.com/Health-Cover (8 hours)
https://s2.googleusercontent.com/s2/favicons?domain_url=worldeducationfair.com (8 hours)
https://s2.googleusercontent.com/s2/favicons?domain_url=www.Dulux.in (8 hours)
https://s2.googleusercontent.com/s2/favicons?domain_url=www.asianpaintshomesolutions.com (8 hours)
https://s2.googleusercontent.com/s2/favicons?domain_url=www.principalretirementindia.com (8 hours)

解决方案

All of the listed resources seem to be external. You cannot add/modify headers and/or caching behavior in general for external resources, hence there is nothing you can to about that.

Just make sure that all resources under your control (coming from your server(s) and or CDN) properly leverage caching.

这篇关于新增ExpiresByType为.htaccess,但PageSpeed​​见解还是说我应该&QUOT;利用浏览器缓存&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆