views:

30

answers:

2

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?

+1  A: 

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

hellvinz
My server automatically sets Pragma to no-cache (which I do not have access to change). So I want to change the pragma value to something more consistent with the cache settings I outlines above, or somehow null out the entire pragma field, all via my php script. Any ideas?
Drew2345
if it's apache, it is taking .htaccess into account and have the headers module you can use this directive "Header unset Pragma"
hellvinz
I don't think the mod_headers.c is activated.
Drew2345
then it will be difficult to disable the pragma: no-cache. It seems that there is a precedence between Cache-Control and Pragma directive, and that in HTTP 1.1 Pragma is ignored if Cache-Control is set. Have a look at the directive precedence part in this documentation http://www.mnot.net/javascript/xmlhttprequest/cache.html
hellvinz
What about this: header('Cache-Control: private, max-age=28800, must-revalidate'); header('Expires:' . gmdate('D, d M Y H:i:s T', strtotime('+8 hours'))); header('Pragma: private');
Drew2345
You can try, maybe you webserver is not overriding pragma if it is set by the application.
hellvinz
A: 

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
AlexV