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
Register
Register | 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
Reply
 
Thread Tools 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
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. :)
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
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
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
Default

That worked. Thanks for your help!
Reply With Quote
Reply


Thread Tools
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 06: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 04:35 AM



All times are GMT -4. The time now is 05:52 AM.


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