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

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


I had a similar problem with Pragma: nocache

session_cache_limiter(false); prior to session_start(); seemed to suppress it.


Create a simple file that includes none of your PHP libraries but lives in the same folder as the file that serves up your images through a PHP file.

file: test.php

Request this file through a browser and check the headers. If you see the Response headers that you don't want, you know that they're configured via apache and not generated via a PHP file and you can concentrate your searches on .htaccess file in the directory tree, and on the http.confg and other included apache config files. You'll want to search for

<Directory....

and

<VirtualHost

sections that may apply to your site.

If you don't see the headers in a request for that simple PHP file, you know that PHP is setting the headers somewhere. At the end of your image serving file (or right after it echos the image and exits), but the following PHP snippet)

var_dump(get_included_files());

Request an image through the image serving URL. That above snippet will print out all the PHP files used in the request. (you'll probably need to view source or use curl to see the raw output, as the browser will report an invalid image)

Having a subset of your files to work file, search through them for calls to the

header();

function. The header function is the only way (I think) that raw PHP code can set Response headers. You'll also want to search for

call_user_func
eval
$$

in case there's any dynamic code on the page that's using PHP's meta-programming capabilities to call the header function.

Good luck!