Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Refresh an HTML page.

Posted on 1998-12-01
4
Medium Priority
?
230 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 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

885 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