Is there any foolproof way to disable caching of everything on a page (page, CSS, JS, images, etc.)? I've used Pragma and Cache-control, but they still gave me cached images.

Maybe I'm using them wrong? I have the lines


Code:
header('Expires: Sat, 1 Jan 2000 00:00:00 GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');


in a file called dochead.inc that gets include('d by every page. Does that (meaning having it in an include( instead of adding that code directly) break the cache-control stuff?
Those headers only apply to the page itself. You'd have to make the webserver return the same headers on images fetched as well, which could be a bit awkward. Sad
So it doesn't matter that the actual header(s aren't in the page itself, right?

Too bad images aren't affected. I don't understand .htaccess or stuff like that Sad
Deep Thought wrote:
So it doesn't matter that the actual header(s aren't in the page itself, right?

Too bad images aren't affected. I don't understand .htaccess or stuff like that Sad
Take a look at this for a nice simple explanation of the proper .htaccess implementation:

http://www.webmasterworld.com/apache/3540207.htm
The most reliable way I've found is to send a dummy query parameter along with every request that changes each time; for example, file.jpg?refresh=<random number>. As long as the parameter changes each time the browser should not cache the file.

Bear in mind that older versions of IE will refuse to download data (displaying HTTP 404 instead) if you send any cache-related headers when using SSL (https://). I think the idea is that IE is trying to avoid putting encrypted content in the unencrypted cache in case it receives a header telling it to cache the content but ends up doing so in a rather excessive manner.
KermMartian wrote:
Deep Thought wrote:
So it doesn't matter that the actual header(s aren't in the page itself, right?

Too bad images aren't affected. I don't understand .htaccess or stuff like that Sad
Take a look at this for a nice simple explanation of the proper .htaccess implementation:

http://www.webmasterworld.com/apache/3540207.htm


Oh, thanks. That would affect images and other media as well?
I believe so! Your best way to be sure would be to drop that into your htaccess and give it a try. You can also wrap it in a FilesMatch (as the target page says) in order to limit to a particular file or filetype.
The real question is WHY do you want to disable caching? That is going to be terrible for the server AND terrible for clients.

Whatever you are trying to do, you are going about it in a very wrong way.

But to answer your question, no, there is no way. Those headers are more suggestions than requirements - and mobile browser in particular tend to completely ignore them.
Kllrnohj wrote:
The real question is WHY do you want to disable caching? That is going to be terrible for the server AND terrible for clients.
Yeah, that really should have been my first question. I made the perhaps fallacious assumption that it was for a signature bar that would show the progress of some project.
I just realized I don't actually need it for my webpages... For sigs I guess changing the URL would work. Thanks anyway, it might come in handy later Smile
Deep Thought wrote:
I just realized I don't actually need it for my webpages... For sigs I guess changing the URL would work. Thanks anyway, it might come in handy later Smile
Sure thing. I do hope that you manage to come up with a solution that doesn't involve cache-busting for functionality and politeness reasons. Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement