什么是HTTP标头If-None-Match:*是什么意思? [英] What does the HTTP header If-None-Match: * mean?

查看:3515
本文介绍了什么是HTTP标头If-None-Match:*是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下HTTP 1.1标头是什么意思?

What does the following HTTP 1.1 header mean?


If-None-Match:*

If-None-Match: *

我在使用强弱或弱ETag甚至是ETag列表时理解它,但我不明白它在使用星号(*)时的用法。

I understand it when using a strong or weak ETag or even a list of ETags, but I don't understant it's use when using star (*).

编辑很高兴有一些伪代码(PHP代码也很好)可以显示如何/如何回答If-None-Match:* 。

Would be nice to have some pseudocode (PHP code good also) that would show how/what to answer to "If-None-Match: *".

推荐答案

答案是:它取决于。

假设我们已收到

If-None-Match: *
If-Modified-Since: <yesterday date>

页面已被今天更改。

首先,我们看一下 * ,它告诉我们:如果资源在那里并且满足条件(2)则返回304 。很好,资源存在,但条件(2)规定:只返回304,如果日期晚于当前。所以这个条件不符合,页面将完全交付。

First, we take a look at the * which tells us: "Return 304 if the resource is there and condition (2) is met". Fine, the resource exists, BUT condition (2) states: "Only return 304, if the date is later than current". So this condition is not met, and the page will be delivered completely.

如果我们还没有收到 If-Modified-Since ,响应将是304。

If we hadn't received If-Modified-Since, the response would have been 304.

如果资源在请求时不存在,我们已经返回了相应的代码(好像有否 If-None-Match )。

If the resource hadn't existed upon request, we'd have returned the appropriate code (as if there was no If-None-Match).

304只应返回以响应GET和HEAD请求,并且所有与缓存相关的响应头都必须存在。对于所有其他类型的请求,您的服务器需要回答412(前置条件失败)。

304 should only be returned in response for GET and HEAD requests, and all cache-related response headers have to be there. For all other types of request your server needs to be answering 412 (Precondition failed).

我希望它有所帮助;)

这篇关于什么是HTTP标头If-None-Match:*是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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