浏览器使用什么启发式方式来缓存资源,而不是明确设置为可以缓存的? [英] What heuristics do browsers use to cache resources not explicitly set to be cachable?

查看:1124
本文介绍了浏览器使用什么启发式方式来缓存资源,而不是明确设置为可以缓存的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于原始服务器并不总是提供明确的到期时间,所以HTTP缓存通常分配启发式到期时间,采用使用其他报头值(例如上次修改时间)的算法来估计合理的到期时间。 HTTP / 1.1规范没有提供特定的算法,但对结果施加了最坏情况的限制。由于启发式到期时间可能会影响语义透明度,因此应谨慎使用,并鼓励原始服务器尽可能提供明确的到期时间。
HTTP / 1.1 RFC 2616




浏览器使用什么算法来估计合理的到期时间?

理想答案将覆盖所有主要浏览器从源代码或官方博客文章。
解决方案

此博客文章说,Internet Explorer 9使用 max- age =(DownloadTime - LastModified)* 0.1 http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx

与Mozilla实际上是一样的(这篇文章比较老,我不知道它是否已经改变了): https://developer.mozilla.org/zh-CN/docs/HTTP_Caching_FAQ


13.2.2 Heuristic Expiration

Since origin servers do not always provide explicit expiration times, HTTP caches typically assign heuristic expiration times, employing algorithms that use other header values (such as the Last-Modified time) to estimate a plausible expiration time. The HTTP/1.1 specification does not provide specific algorithms, but does impose worst-case constraints on their results. Since heuristic expiration times might compromise semantic transparency, they ought to used cautiously, and we encourage origin servers to provide explicit expiration times as much as possible. HTTP/1.1 RFC 2616

What are the algorithms used by browsers to estimate plausible expiration times?

The ideal answer will cover all major browsers with evidence from source code or official blog posts.

解决方案

This blog post says that Internet Explorer 9 uses max-age = (DownloadTime - LastModified) * 0.1: http://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx

Which is effectively the same as Mozilla (this post is rather old, I don't know if it has changed since): https://developer.mozilla.org/en-US/docs/HTTP_Caching_FAQ

这篇关于浏览器使用什么启发式方式来缓存资源,而不是明确设置为可以缓存的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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