Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2003, 05:16 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Preventing Page Caching

I need to create a page with a link to a text file (for the user to save) that must not be cached. The name of the text file will remain the same, but the content will change based on previous user actions. I tried the "no-cache" option in the head...but that didn't help. Any advice will be greatly appreciated.
 
Old June 3rd, 2003, 06:18 PM
Registered User
 
Join Date: Jun 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Which web server are you using?

If IIS, (and you have Admin access) open IIS Manager, right-click on your text file, select properties, then go to the HTTP Headers tab. From there, Enable Content Expiration and select Expire Immediately. This should cause an entry in the HTTP header that a properly-behaving cache should obey and not store the information. If that doesn't work, sometimes you can play around with Expire After (Set it to 0 or 1 minute) and Expire On (Set to a prior date) to get it to work. Some caches are nonobedient, and sometimes IIS does weird unexpected things.

In Apache, you can use the functionality of the Apache module mod_expires. It's included with the base Apache source, but I don't think it is compiled by default. You'll need to check to see if it was included during compilation. (If not, use APXS to add it (apxs -i -a -c mod_expires.c) then restart Apache) I don't think it is added by default.

With mod_expires in place, add something like this to httpd.conf:
Code:
<IfModule mod_expires.c>
  <Location /relative/path/to/textfile.txt>
     ExpiresActive On
     ExpiresDefault Now
  </Location>
</IfModule>
For more info on mod_expires see http://httpd.apache.org/docs/mod/mod_expires.html

If you are using a different web server, I have no idea. :)
 
Old June 4th, 2003, 03:44 AM
lp lp is offline
Registered User
 
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've never experienced any problems related to caching when it comes to static files such as text-files and IIS, but anyhow:
As Klom Dark says, you could add http-headers.
But I would add the header:
'cache-control'
set to the value:
'no-cache'
- this should also prevent web-proxies from caching the file so that the client always gets the file direct from your server.

Cahce-control header:
http://www.w3.org/Protocols/rfc2616/...4.html#sec14.9
 
Old June 5th, 2003, 01:19 PM
Registered User
 
Join Date: Jun 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That worked. Thanks for your help!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing page refresh from asp.net button hericles ASP.NET 1.0 and 1.1 Professional 2 October 8th, 2008 04:29 PM
Page caching cridley ASP.NET 1.x and 2.0 Application Design 3 January 9th, 2006 07:58 PM
Preventing access to a page in PHP Steve777 PHP How-To 1 July 22nd, 2005 01:18 PM
Preventing tab controls from changing page badgolfer VS.NET 2002/2003 2 December 17th, 2003 05:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.