[nycphp-talk] Caching only images

Chris Shiflett shiflett at
Fri Apr 4 00:18:21 EST 2003

--- NYPHP <xml at> wrote:
> Here seems some hope, then i would like to know what are those proper
> "caching headers set" that i need to set in my php script. Consider below
> example of function header. (page will be cached for for 1 day, including
> all objects that reside in it)
> header("Cache-Control: max-age=86400, must-revalidate");
> Above function caches page on client or isp (for now forget where it
> stores), BUT it stores whole document. While i need to store only IMAGES
> that resides in this document. So do ineed to write above header in some
> other way so that it will cache only images rather than docment?

Embedded resources such as images are fetched with a separate HTTP request.
What does this mean? It means that the HTTP headers you use in blah.php do not
affect the caching behavior of images within blah.php in any way.

If your images are generated by a PHP script (for example, you use <img
src="/image_generator.php">), then you can use header() calls in the
image_generator.php script to alter the headers of images.

Otherwise (this is the more common case), the headers returned for images
relies completely on your Web server and has nothing to do with your PHP.

Hope that helps; I actually wasn't following this thread, but I wanted to throw
that in. It has been known to cause great confusion (and I'm not entirely sure
I explained it clearly).


Become a better Web developer with the HTTP Developer's Handbook

More information about the talk mailing list