我的 Pragma HTTP 响应标头应设置为什么?

发布于 2024-09-25 13:32:34 字数 216 浏览 2 评论 0原文

我将与缓存相关的标头设置为在八小时后过期,如下所示...

header('Cache-Control: max-age=28800');
header('Expires:' . gmdate('D, d M Y H:i:s T', strtotime('+8 hours')));

在这种情况下,我的 Pragma HTTP 响应标头应该设置为什么?

I have my cache related headers set to expire at eight hours as follows...

header('Cache-Control: max-age=28800');
header('Expires:' . gmdate('D, d M Y H:i:s T', strtotime('+8 hours')));

With that being the case, what should my Pragma HTTP response header be set to?

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

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

发布评论

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

评论(2

浮华 2024-10-02 13:32:34

您不必设置 pragma,仅当您想要无缓存指令时才设置 pragma。请参阅此处以获取更多信息: http://www.w3 .org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32

You don't have to set pragma, pragma is set only if you want a no-cache directive. Have a look here for more information: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32

亽野灬性zι浪 2024-10-02 13:32:34

请参阅 PHP 文档以了解 session_cache_limiter。您将看到要发送的正确缓存标头:

public:

Expires: (sometime in the future, according session.cache_expire)
Cache-Control: public, max-age=(sometime in the future, according to session.cache_expire)
Last-Modified: (the timestamp of when the session was last saved)

private_no_expire:

Cache-Control: private, max-age=(session.cache_expire in the future), pre-check=(session.cache_expire in the future)
Last-Modified: (the timestamp of when the session was last saved)

private:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, max-age=(session.cache_expire in the future), pre-check=(session.cache_expire in the future)
Last-Modified: (the timestamp of when the session was last saved)

nocache:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache

See the PHP doc for session_cache_limiter. You will see the correct cache headers to send:

public:

Expires: (sometime in the future, according session.cache_expire)
Cache-Control: public, max-age=(sometime in the future, according to session.cache_expire)
Last-Modified: (the timestamp of when the session was last saved)

private_no_expire:

Cache-Control: private, max-age=(session.cache_expire in the future), pre-check=(session.cache_expire in the future)
Last-Modified: (the timestamp of when the session was last saved)

private:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, max-age=(session.cache_expire in the future), pre-check=(session.cache_expire in the future)
Last-Modified: (the timestamp of when the session was last saved)

nocache:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文