避免304(未修改)响应 [英] Avoiding 304 (not modified) responses

查看:1605
本文介绍了避免304(未修改)响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它是一个 ExpiresDefault 的Apache足以避免HTTP状态从服务器304的响应?我已设置 ExpiresDefault访问加10年,但我仍然看到与GET /资产/模板/默认304响应日志条目/css/style.min.css?v=1 HTTP / 1.1每当我打开任何网页上的本地 phpMyFAQ的网站。清空浏览器缓存似乎并没有改变任何东西。

Is it an ExpiresDefault Apache directive enough to avoid HTTP Status 304 responses from the server? I have set ExpiresDefault "access plus 10 years" but I'm still seeing log entries with a 304 response for "GET /assets/template/default/css/style.min.css?v=1 HTTP/1.1" whenever I open any page on a local PHPMyFAQ site. Emptying the browser cache doesn't seem to change anything.

推荐答案

到期日:头您的服务器发送无关未来304的响应。它仅提供了多久,他们可以考虑资源之前等待的估计到客户端/代理过时。客户是不是的需要的遵守此头和可以自由地继续对同一资源进行新的请求,如果他们的愿望。因此,要回答你的问题在​​短期:

The Expires: header your server sends out has nothing to do with future 304 responses. It provides only an estimate to clients/proxies for how long they can wait before considering a resource "stale." Clients aren't required to observe this header and are free to continue making new requests for the same resource if they wish. So, to answer your question in short:

没有,你就永远无法为p $ pvent用户明确美元,对于不管是什么头可以发送相同的资源进行新的请求。

No, you'll never be able to explicitly prevent users from making new requests for the same resource regardless of what headers you send.

304响应是匹配的结果如果-匹配的If-Modified-Since的在头客户机请求。这里发生的是您的服务器发送出去要么/或/都与原来的答复如下头:

The 304 response is the result of a matching If-Match or If-Modified-Since header in the client request. What's happening here is your server is sending out either/or/both of the following headers with its original response:


  • 的ETag

  • 的Last-Modified

  • ETag
  • Last-Modified

客户端则发回下列头与他们的要求,看是否资源已经从他们的缓存版本更改:

Clients then send back the following headers with their requests to see if the resource has changed from their cached version:


  • 如果-匹配(ETag的)

  • 的If-Modified-Since的(的Last-Modified)

  • If-Match (ETag)
  • If-Modified-Since (Last-Modified)

如果这些条件为真,那么服务器会送你观察到的 304未修改响应,客户端就会知道它可以安全地满足了它的缓存版本的资源。

If either of these conditions is true then the server will send the 304 Not Modified response you've observed and the client will know it can safely serve up its cached version of the resource.

符合注意

2616 第14.21 实际发送<$ C禁止兼容的服务器$ C>过期头一年以上在未来,所以你不应该使用的访问加10年的摆在首位:

RFC 2616 Section 14.21 actually prohibits compliant servers from sending Expires headers more than one year in the future, so you shouldn't be using "access plus 10 years" in the first place:

HTTP / 1.1服务器不应发送过期日期在未来的一年以上。

HTTP/1.1 servers SHOULD NOT send Expires dates more than one year in the future.

这篇关于避免304(未修改)响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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