Solved

Refresh an HTML page.

Posted on 1998-12-01
4
168 Views
Last Modified: 2010-04-09
Hello there.

I have a script which updates HTML pages on my site.
But the users of the sites see the version on their cache and not the new updated one.

How can I force any new request for an updated page to get the new one, instead of the cached one?
0
Comment
Question by:semuel
  • 2
4 Comments
 
LVL 1

Expert Comment

by:squimph
ID: 1840135
For netscape users, you can use a "no-cache" directive in the <HEAD> section of your HTML pages like this:

<head>
<meta http-equiv="Pragma" content="no-cache">
</head>

MS internet explorer uses something different (grr!). For MSIE, apparently you have to use something like this:

<head>
<META HTTP-EQUIV="Expires" CONTENT="Tue, 04 Dec 1993 21:29:02 GMT">
</head>

Notice the date in the above is already past. (I got this hint from http://www.microsoft.com/workshop/author/support/faq.asp)
0
 
LVL 1

Author Comment

by:semuel
ID: 1840136
Hello squimph.

It's a nice answer, but not what I've asked.
in your way, the browser will never use his cache, and always will refresh the page.

what I want is to cause the browser to compare the file's date, and if the file changed from the last time it was cached, it'll refresh.
of course, it's resnable to think that it'll happend anyway, but it's not the case.
I'm using netscape and Apache server.

thanks.
0
 
LVL 1

Accepted Solution

by:
squimph earned 50 total points
ID: 1840137
I'm afraid "don't cache" may be the best option available. Browsers *DO* check the last modified date of the HTML document and load a fresh copy if it's changed (it's called a conditional GET)... the problem is, most browsers default setting is to check the date only once each time the browser has loaded.

There is a setting to "check date each time" but you have to go into the settings panel to manually set that... something you can't count on users doing. (The setting in MSIE 4 is buried under View -> Internet options -> General -> Temporary internet files -> Settings. In Netscape 4 it's under Edit -> Preferences -> Advanced -> Cache)

You can try putting an "expires" tag in your pages as I mentioned above with the time of the next update for the HTML page. There is also an Apache add-in module that sets "expires" headers automatically for selected files, but I understand netscape ignores "expires".

Using a "no-cache" tag may not be as bad as it sounds... it applies only to the HTML, not all the images associated with a page. Usually the images are what take time to load, so depending on how large your pages are, forcing the browser to download just the html each time might not be that bad.
0
 
LVL 3

Expert Comment

by:bigelos
ID: 1840138
Actually, just use the expires tag (and Netscape does use the tag) the way it was originally supposed to be used.  Set the page to expire when you expect to have new code up.  (Yeah, I know, this requires planning ahead...)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now