PHP produced Images: no-cache

I am using

ExpiresByType image/gif "access plus 30 days"

to set the cache-control for images on my server.

Now I have one image, that is produced by php. This image should not be cached.
But if I add a

header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0,pre-check=0");

the output will be

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=2592000

What could I to to keep the cache information for images in general, but not have the 30 days (max-age=2592000) added to this one particular image?


Have you tried setting a max-age in your header to override the default?

Use a <Files> that applies to the single file, and contains an [url=]ExpiresActive directive which turns off mod_expires for that particular file.

OK, thanks, that was a good idea

So I can either turn it off for all PHP files:

<Files ~ "\\.(php)$">
ExpiresActive Off

Or only define caching for PHP GIFS:

<Files ~ "\\.(php)$">
ExpiresByType image/gif "access plus 10 minutes"