网页优化之 304 mot modified 和 200 from cache

发布时间: 2014-12-07 04:34:00

refer to:

基本上, 200(from cache) 是速度最快的,因为不需要访问远程服务器,直接使用本地缓存.

304 的过程是, 先请求服务器, 然后服务器告诉我们这个资源没变, 浏览器再使用本地缓存.

结论: 需要设置 200 from cache. 这样才是解决问题之道. 

200 (cache) means Firefox is simply using the locally cached version. This is the fastest because no request to the Web server is made.

304 means Firefox is sending a "If-Modified-Since" conditional request to the Web server. If the file has not been updated since the date sent by the browser, the Web server returns a 304 response which essentially tells Firefox to use its cached version. It is not as fast as 200 (cache) because the request is still sent to the Web server, but the server doesn't have to send the contents of the file.