2010-09-29 132 views
0

我有我的缓存相关的头设置中的8小时到期如下...我的Pragma HTTP响应头文件应该设置为?

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

有了这样的情况下,我应该我的语用HTTP响应头被设置为?

回答

2

您不必设置杂注,仅当您需要no-cache指令时才设置杂注。在此处查看更多信息:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32

+1

我的服务器自动将Pragma设置为no-cache(我无权修改)。所以我想将附注值更改为与上面概述的缓存设置更一致的内容,或者通过我的PHP脚本以某种方式将整个编译指示字段清空。有任何想法吗? – Drew2345 2010-09-29 14:19:46

+1

如果它是apache,它将.htaccess考虑在内,并有头文件模块,你可以使用这个指令“头文件unset Pragma” – hellvinz 2010-09-29 14:30:38

+0

我不认为mod_headers.c被激活。 – Drew2345 2010-09-29 14:44:12

1

请参阅PHP文档session_cache_limiter。您将看到正确的缓存头派:

市民:

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