http Pragma 的有效值是多少

发布于 2024-12-04 03:09:25 字数 141 浏览 1 评论 0原文

http header pragma 的有效值是多少。我知道 no-cache 是其中之一,但我想要启用缓存,所以我应该设置它。我做了一些谷歌搜索,我得到的只是大多数客户忽略了这一点,但没有关于它接受的其他值的信息。

What are the valid values for http header pragma . I know no-cache is one but i wnat to enable caching so what should i set it. I did some googleing and all that i got was most clients ignore this but no info on other values it accepts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁月蹉跎了容颜 2024-12-11 03:09:25

令人惊讶的是,默认情况下只定义了一个参数,即 no-cache,并且根据 RFC,HTTP 中不会定义新的 Pragma 指令。

参考:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14。 html#sec14.32

此外,您将需要使用 Cache-Control 标头来管理缓存行为而不是 Pragma 指令,后者似乎仍然只是为了支持旧版 HTTP/1.0。

参考:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14。 html#sec14.9

奖励:http://www.mnot.net/cache_docs/

Surprisingly there is only one parameter defined by default, which is no-cache and no new Pragma directives will be defined in HTTP as per RFC.

ref: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32

Moreover, you will need to use the Cache-Control header for managing the caching behaviors rather than the Pragma directive which seems to be still included only to support the legacy HTTP/1.0.

ref: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

Bonus: http://www.mnot.net/cache_docs/

半葬歌 2024-12-11 03:09:25

您可能正在寻找 Cache-Control,这个在 HTTP/1.1 中受支持,并且定义了比 编译指示

You're probably looking for Cache-Control, this is supported in HTTP/1.1 and defines more states than Pragma.

初相遇 2024-12-11 03:09:25

更多信息,可能会帮助一些对缓存不太感兴趣、对 http 标头更感兴趣的人。即原始问题的字面解释“http header pragma 的有效值是什么”?

接受的答案(https://stackoverflow.com/a/7376516/3246928)中的参考是 RFC http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32。它将 snytax 定义为:

Pragma = "Pragma" ":" 1#pragma-directive

pragma-directive = "无缓存" |扩展编译指示

extension-pragma = token [ "=" ( token | Quoted-string ) ]

暗示任何“token=value”对都是可接受的(值是可选的)。规范继续说

HTTP 中不会定义新的 Pragma 指令。

我猜这也意味着涵盖“扩展编译指示”部分,但我希望它们在这里更加明确。

这个标头似乎不是专门为缓存创建的; RFC 中的描述说:

Pragma 通用头字段用于包含实现 -
可能适用于沿途任何收件人的具体指令
请求/响应链

因此,理论上,您可以在此处添加内容,并且它们可以工作。然而,尽管进行了大量搜索,我还没有找到任何对此处使用过的任何其他值的引用。它实际上是 http/1 中死气沉沉且令人尴尬的部分。

看起来正常的做法是:

Some more information, that might help some people that are less interested in caching, and more interested in http headers in general. i.e the literal interpretation of the original question, "what are the valid values for the http header pragma"?

The reference in the accepted answer (https://stackoverflow.com/a/7376516/3246928) is the RFC http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32. It defines the snytax as:

Pragma = "Pragma" ":" 1#pragma-directive

pragma-directive = "no-cache" | extension-pragma

extension-pragma = token [ "=" ( token | quoted-string ) ]

This implies that any 'token=value' pair is acceptable (with the value being optional). The spec goes on to say

No new Pragma directives will be defined in HTTP.

and I would guess this is also meant to cover the "extension-pragma" part, but I wish they had been more unambiguous here.

This header does not seem to be specifically created for caching; the description in the RFC says:

The Pragma general-header field is used to include implementation-
specific directives that might apply to any recipient along the
request/response chain

So, in theory, you could add things here, and they could work. However, despite much searching, I have not found any reference to any other values ever being used here. It is effectively a dead and embarrassing part of http/1.

It seems like the normal thing to do is:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文