适用于Facebook JS SDK和Google Analytics(分析)的标题 [英] Expires header for Facebook JS SDK and Google Analytics
问题描述
我们都知道,将静态资源添加到未来的到期日是提高网站页面加载速度的好习惯。所以我们已经确保了所有的资源,但是所有普通的Facebook JS SDK和Google Analytics(分析)都不会这样做,从而降低整个页面的速度分数。
We all know adding a far-future expiration date to static resources is a good practice to increase our websites' page load speed. So we've ensured it for all of our resources BUT the all-too-common Facebook JS SDK and Google Analytics don't do that and thus lower the entire page's speed score.
检查标题显示Facebook做20分钟:
Cache-Control public,max-age = 1200
连接keep-alive
内容类型application / x-javascript; charset = utf-8
日期星期二,2014年9月23日04:46:38 GMT
Etag566aa5d57a352e6f298ac52e73344fdc
到期星期二,2014年9月23日05:06:38 GMT
Examining the headers shows Facebook do 20 minutes: Cache-Control public, max-age=1200 Connection keep-alive Content-Type application/x-javascript; charset=utf-8 Date Tue, 23 Sep 2014 04:46:38 GMT Etag "566aa5d57a352e6f298ac52e73344fdc" Expires Tue, 23 Sep 2014 05:06:38 GMT
和Google Analytics(分析)做2个小时:
主要价值
回应HTTP / 1.1 200 OK
日期星期二,2014年9月23日04:45:49 GMT
过期星期二,2014年9月23日06:45:49 GMT
最后修改星期一,2014年9月08日18:50:13 GMT
X内容类型选项nosniff
内容 - 类型文本/ javascript
服务器Golfe2
年龄1390
缓存控制public,max-age = 7200
备用协议80:quic,p = 0.002
内容 - 长度16,062
and Google Analytics do 2 hours: Key Value Response HTTP/1.1 200 OK Date Tue, 23 Sep 2014 04:45:49 GMT Expires Tue, 23 Sep 2014 06:45:49 GMT Last-Modified Mon, 08 Sep 2014 18:50:13 GMT X-Content-Type-Options nosniff Content-Type text/javascript Server Golfe2 Age 1390 Cache-Control public, max-age=7200 Alternate-Protocol 80:quic,p=0.002 Content-Length 16,062
有没有办法强迫他们更长的到期日期?
Is there a way to force them to longer expiration dates?
推荐答案
最终实现的解决方案是移动到Facebook的rediret API,它不会强制在每个页面加载时加载脚本。实际上StackOverflow在这里也是如此。在私人/无痕式浏览器中开始会话,您会看到。
此链接可能有助于: https://developers.facebook.com/docs/ php / howto / example_facebook_login
The solution finally implemented was to move to Facebook's rediret API which doesn't force loading their script on each page load. It's actually what StackOverflow does here as well. Start a session in a private/incognito browser and you'll see. This link might help: https://developers.facebook.com/docs/php/howto/example_facebook_login
这篇关于适用于Facebook JS SDK和Google Analytics(分析)的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!