本文介绍了没有过期的标头发送,内容被缓存,浏览器有条件的GET请求需要多长时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假定浏览器为默认设置,并且内容发送时没有标头过期.

Assume browser default settings, and content is sent without expires headers.

  1. 用户访问网站,浏览器缓存图像等.
  2. 用户不关闭浏览器或刷新页面.
  3. 用户继续正常浏览网站.
  4. 假定浏览器由于任何原因没有转储缓存.

浏览器将在用户浏览时缓存图像等,但是尚不清楚何时会发出条件GET请求以询问内容新鲜度(除了刷新页面外).如果这是特定于浏览器的设置,那么在哪里可以看到它的值(对于safari,IE,FireFox,Chrome等浏览器).

The browser will cache images etc as the user surfs, but it's unclear when it will issue a conditional GET request to ask about content freshness (apart from refreshing the page). If this is a browser specific setting, where can I see it's value (for browsers like: safari, IE, FireFox, Chrome).

[edit:是-我了解您应该始终发送expires标头.但是,这项研究的目的是了解浏览器如何处理不带标头的内容.]

[edit: yes - I understand that you should always send expires headers. However, this research is aimed at understanding how the browser works with content w/o expires headers.]

推荐答案

HTTP/1.1定义了一些缓存机制; expires 标头仅仅是一个,还有 cache-control 标头.

HTTP/1.1 defines a selection of caching mechanisms; the expires header is merely one, there is also the cache-control header.

要直接回答您的问题:对于没有 expires 标头返回的资源,必须考虑返回的 cache-control 指令.

To directly answer your question: for a resource returned with no expires header, you must consider the returned cache-control directives.

HTTP/1.1对于没有与缓存相关的标头提供服务的资源,没有定义任何缓存行为.如果发送的资源没有 cache-control expires 标头,则必须假定客户端在下次请求相同资源时将发出常规(无条件)请求

HTTP/1.1 defines no caching behaviour for a resource served with no cache-related headers. If a resource is sent with no cache-control or expires headers you must assume the client will make a regular (non-conditional) request the next time the same resources is requested.

任何偏离此行为的行为都将客户端视为不是完全合格的HTTP客户端,在这种情况下,问题就变成了:不合格的HTTP客户端应期待什么行为?没有办法回答.

Any deviation from this behaviour qualifies the client as being not a fully conformant HTTP client, in which case the question becomes: what behaviour is to be expected from a non-conformant HTTP client? There is no way to answer that.

HTTP缓存很复杂,要完全了解给定客户端在特定情况下应执行的操作,请阅读并了解 HTTP缓存规范.

HTTP caching is complex, to fully understand what a conformant client should do in a given scenario, read and understand the HTTP caching spec.

这篇关于没有过期的标头发送,内容被缓存,浏览器有条件的GET请求需要多长时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 05:57