Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 3rd, 2003, 05:16 PM
Registered User
Join Date: Jun 2003
Location: , , USA.
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.
Reply With Quote
  #2 (permalink)  
Old June 3rd, 2003, 06:18 PM
Registered User
Join Date: Jun 2003
Location: Omaha, Nebraska, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts

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:
<IfModule mod_expires.c>
  <Location /relative/path/to/textfile.txt>
     ExpiresActive On
     ExpiresDefault Now
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. :)
Reply With Quote
  #3 (permalink)  
Old June 4th, 2003, 03:44 AM
lp lp is offline
Registered User
Join Date: Jun 2003
Location: Sundsvall, , Sweden.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

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:
set to the value:
- 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:
Reply With Quote
  #4 (permalink)  
Old June 5th, 2003, 01:19 PM
Registered User
Join Date: Jun 2003
Location: , , USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

That worked. Thanks for your help!
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 11:15 PM.

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