Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What could be adding "Pragma:no-cache" to my response Headers? (Apache, PHP)

I have a website which maintenance I've inherited, which is a big hairy mess.
One of the things I'm doing is improving performance. Among other things, I'm adding Expires headers to images.

Now, there are some images that are served through a PHP file, and I notice that they do have the Expires header, but they also get loaded every time.

Looking at Response Headers, I see this:

Expires Wed, 15 Jun 2011 18:11:55 GMT Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma  no-cache 

Which obviously explains the problem.

Now, I've looked all over the code base, and it doesn't say "pragma" anywhere. .htaccess doesn't seem to have anything related either.

Any ideas what could be setting those "pragma" (and "cache-control") headers, and how can I avoid it?

like image 203
Daniel Magliola Avatar asked Jun 15 '10 18:06

Daniel Magliola


People also ask

What is Pragma no-cache header?

"The Pragma: no-cache header field is an HTTP/1.0 header intended for use in requests. It is a means for the browser to tell the server and any intermediate caches that it wants a fresh version of the resource, not for the server to tell the browser not to cache the resource.

What is Pragma in header?

The Pragma HTTP/1.0 general header is an implementation-specific header that may have various effects along the request-response chain. This header serves for backwards compatibility with the HTTP/1.0 caches that do not have a Cache-Control HTTP/1.1 header.

What is incomplete or no-cache-control and pragma HTTP header set?

The 'Cache-control' HTTP header holds instructions for caching in both requests and responses. Because the 'Pragma' header is used for backwards compatibility with HTTP/1.0 where the 'Cache-control' header is not yet presented. If sensitive information in application responses is stored in the local cache.

What does no-cache cache directive do?

no-cache. The no-cache response directive indicates that the response can be stored in caches, but the response must be validated with the origin server before each reuse, even when the cache is disconnected from the origin server.


1 Answers

The culprit may be php.ini, where session.cache_limiter=nocache. Change the value to blank or public to avoid the anti-cacheing headers.

like image 58
technomage Avatar answered Sep 19 '22 02:09

technomage