Solved

Refresh an HTML page.

Posted on 1998-12-01
4
190 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

803 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