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

时间:2010-09-29 14:06:14

标签: php http-headers

我的缓存相关标头设置为在8小时后到期,如下所示......

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

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

2 个答案:

答案 0 :(得分:3)

您不必设置编译指示,仅当您需要no-cache指令时才设置编译指示。有关详细信息,请查看此处:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32

答案 1 :(得分:1)

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

公共:

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)

私人:

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)

非缓存:

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