Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wanting to use no-cache for text/content but not images

Status
Not open for further replies.

Tama

MIS
Jun 6, 2001
121
NZ
I'm running a dynamic MySQL/PHP website. To prevent some ISPs from ignoring the Meta/Pragma fields in the HEAD section of the webpages I have added the following lines just before the document is generated.

Code:
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0

This has been working really well and my users are no longer getting confused when they recieve out of date/ other users pages.

The problem is that it seems to also affect the images on the webpages, and some are quite graphic heavy (often with re-occuring icons.) This is hard to test because I am on broadband, but once a page is loaded the images load one by one - which suggests that the browser is getting the images off the web server rather than the local drive.

So - my question is - is it possible to define the No-cache to only apply to the text/content of the word pages and not the images?

Any comments, suggestions etc. greatly appreciated.

Cheers
Tama
 
I don't think so.

There's always a better way. The fun is trying to find it!
 
My understanding is that each object on the page is retrieved with a seperate http request and comes with it's own set of headers. So every time the browser hits a <img src=&quot;picture.gif&quot;> tag, it evaluates the cache status of that image depending on the headers sent with the image.

Try typing the URL of the images concerned into , to see what headers are being sent. Maybe if no caching headers are being sent with the images the browser uses the page's settings?

How to specify headers for particular file types is outside my knowledge I'm afraid. If you think this is an avenue worth pursuing (and no-one dives in with an answer), you might need to post an appropriate question in the forum that deals with your webserver (listed in )

-- Chris Hunt
 
Thanks guys

I had a quick play with searchengineworld (which I think I'll have to visit again) and the pages go through with heaps of no-cache controls - the images by themselves don't.

My guess is that the page acts a container - and any obect inside the page has the no-cache rules applied to it. I'll leave this up for a while longer, and then perhaps take Chris's suggestion and visit the Apache forum.

Cheers
Tama

P.S. My site is
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top