NYCPHP Meetup

NYPHP.org

[nycphp-talk] Caching only images

NYPHP xml at aumcomputers.com
Fri Apr 4 00:30:06 EST 2003


Chris,

This is right. I am not generating any images using my php script, those are
just static ones that reside in images directory and is being used in php
scripts. My document outputs 270 kb as results including 100kb of those
static images that remains static all the time. So i assumed that if
somehow, by passing headers or something like that i can tell browser cache
or isp cache to store those images at locally and always using from there
only, whenever requested. So for me my script will output only 170 kb and  i
can handle more clients and can save my bandwidth. But i guess it was my
misunderstanding. what do u think?

Thanks

Anirudh Zala

----- Original Message -----
From: "Chris Shiflett" <shiflett at php.net>
To: "NYPHP Talk" <talk at nyphp.org>
Sent: Friday, 04 April, 2003 10:48 AM
Subject: Re: [nycphp-talk] Caching only images


> --- NYPHP <xml at aumcomputers.com> 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).
>
> Chris
>
> =====
> Become a better Web developer with the HTTP Developer's Handbook
> http://httphandbook.org/
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>
>




More information about the talk mailing list