Solved

Refresh an HTML page.

Posted on 1998-12-01
4
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

623 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