PDA

View Full Version : Cache Control in html



wassim
May 3rd, 2001, 15:07
Hi guys,

I'm having problems to control the expiry date of my pages.
I don't want the browser to load the page from the cache.

What bothers me is that even my interactive pages which are written in ASP load from the cache.
It only happens with Internet Explorer. Netscape doesn't seem to have this kind of problems.

I used all sort of commands to eliminate that problem, like
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
and response.expires and response.cachecontrol in ASP
but the pages still load from the cache.

Anyone has an idea about how to correct that?

Thanks in advance
Wassim

Woofcat
May 3rd, 2001, 20:00
Meta tags aren't meant for this... Have your scripts send "Cache-control: private, no-cache, must-revalidate" and "Pragma: no-cache" headers...

meow
May 3rd, 2001, 22:22
Well, this was up a time ago on a list I read from time to time. I'll do the big boo-boo and quote the post. Note that protests were made against the pragma no-cache. Maybe the links can lead to something.

............Q U O T E...............
This is a persistent problem - and in my experience I've seen many different techniques. The most common is setting the <META> EXPIRES:

<meta http-equiv="Expires" content="Tue, 01 Jan 2000 12:12:12 GMT">

...although this works inconsistently or not at all in Internet Explorer.

There is also the PRAGMA/NO CACHE:

<meta http-equiv="Pragma" content="no-cache">

See this reference:
"Pragma: No-cache" Tag May Not Prevent Page from Being Cached"
http://support.microsoft.com/support/kb/articles/Q222/0/64.ASP


But the best way is to actually generate raw HTTP headers which include these things:

ASP/IIS:
http://support.microsoft.com/support/kb/articles/Q234/0/67.asp
PHP:
http://www.php.net/manual/en/function.header.php
COLD FUSION:
<cfheader name="Expires" value="#Now()#">
<cfheader name="Pragma" value="no-cache">
JSP:
http://www.jguru.com/jguru/faq/printablefaq.jsp?faq=JSP


http://www.delorie.com/web/headers.html is a neat little resource to look at raw HTTP headers. (got this from the link from http://evolt.org/ )

............................................