pagespeed 摘要 - Optimize caching


Leverage browser caching

1.Set caching headers aggressively for all static resources.

Set Expires to a minimum of one month, and preferably up to one year, in the future. (We prefer Expires over Cache-Control: max-age because it is more widely supported.) Do not set it to more than one year in the future, as that violates the RFC guidelines.

 

2.Use fingerprinting to dynamically enable caching.

Google Calendar embeds a fingerprint in its filename:calendar/static/fingerprint_key doozer compiled.css,where the fingerprint key is a 128-bit hexadecimal number.

 

3.Set the Vary header correctly for Internet Explorer.

 

4.Avoid URLs that cause cache collisions in Firefox.

The Firefox disk cache hash functions can generate collisions for URLs that differ only slightly, namely only on 8-character boundaries. Thus, if you are using fingerprinting or are otherwise programmatically generating file URLs, to maximize cache hit rate, avoid the Firefox hash collision issue by ensuring that your application generates URLs that differ on more than 8-character boundaries.

 

5.Use the Cache control: public directive to enable HTTPS caching for Firefox.

 

Leverage proxy caching

You use the Cache-control: public header to indicate that a resource can be cached by public web proxies in addition to the browser that issued the request.

 

1.Don't include a querystring in the URL for static resources.

2.Be aware of issues with proxy caching of JS and CSS files.

Some public proxies have bugs that do not detect the presence of the Content-Encoding response header. This can result in compressed versions being delivered to client browsers that cannot properly decompress the files. Since these files should always be gzipped by your server, to ensure that the client can correctly read the files, do either of the following:

  • Set the the Cache-Control header to private. This disables proxy caching altogether for these resources. If your application is multi-homed around the globe and relies less on proxy caches for user locality, this might be an appropriate setting.
  • Set the Vary: Accept-Encoding response header. This instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed. The correct version of the resource is delivered based on the client request header. This is a good choice for applications that are singly homed and depend on public proxies for user locality.

 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值