Forum Moderators: phranque

Message Too Old, No Replies

preventing caching

         

paste

2:35 pm on Apr 16, 2004 (gmt 0)

10+ Year Member



Basically I want to disallow a page on my server from being cached. How would I got about doing that?

-eric

ogletree

3:10 pm on Apr 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<META content="noarchive" NAME="robots">

Alternative Future

3:16 pm on Apr 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And then there is also this one we use in our JSP's

<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1);
%>

-George

ogletree

3:23 pm on Apr 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Alternative Future I thought that tells peoples computers not to cache not the SE.

Alternative Future

3:29 pm on Apr 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm you could have a point! It happens client-side so would this not have the same affect on SE?

Am open on this one...

-George

jdMorgan

9:22 pm on Apr 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Alternative Future I thought that tells peoples computers not to cache not the SE.

Yes, it works on the client side, and on any intervening network caches that examine the headers.

You can do the same thing at the server level using Apache mod_expires and mod_headers:


# Set up Cache Control headers
ExpiresActive On
<FilesMatch "^.*$">
ExpiresDefault A0
Header unset Cache-Control:
Header append Cache-Control: "no-cache, must-revalidate"
</FilesMatch>

The FilesMatch directive will accept regular expressions specifying any files you want to apply this cache-control to.
<added> I use Header unset followed by Header append instead of Header set. This is a work-around for a bug I once ran into where Header set didn;t work for some reason. </added>

It's not clear yet whether we're discussing ways to inhibit search engine caching or network and client caching, though.

Jim