Welcome to WebmasterWorld Guest from 107.22.87.205

Forum Moderators: phranque

Message Too Old, No Replies

Keep page from being cached?

How do you keep a page from being cached on a visitor's PC?

     
8:05 am on Feb 13, 2004 (gmt 0)

10+ Year Member



I need to keep a particular page from being auto-cached on a user's PC. I have experienced that some visitors' computers are caching my pages, which isn't that big of a problem usually, but this particular page is an order form that changes frequently. Is there any meta code or otherwise to instruct the browser NOT to cache the page?

I'm not seeking to prevent someone from purposefully doing this, only to keep the browser from doing it automatically...?

12:44 pm on Feb 14, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could try these meta tags:

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

I've seen advises to put them at the end of the document as well, like this:

</body>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
</head>
</html>

Can't guarantee that any of this works...

10:30 pm on Feb 14, 2004 (gmt 0)

10+ Year Member



This is difficult to do, even if you use HTTP or HTML headers to say that a file should not be cached, some browsers are configured to ignore this and cache it anyway. Then use the version from the cache for the current session, without checking the server to see if any changes have taken place.

One way to get around this is to trick the browser into thinking that the file is created by a script and could be different each time it is retrieved from the server. You can do that by adding a '?' to the end of the url.
For example
[example.org...]

The webserver will ignore the '?' and still serve up the correct page.

8:26 am on Feb 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's a nice article about preventing caching at h*tp://www.web-caching.com/mnot_tutorial/how.html#CONTROL
 

Featured Threads

Hot Threads This Week

Hot Threads This Month