Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

force browser refresh 2

Status
Not open for further replies.

fluid11

IS-IT--Management
Jan 22, 2002
1,627
0
0
US
I don't know anything about Javascript, but can't Javascript be used to force a users web browser to refresh a page everytime they visit it? I want to make sure that users are always viewing the most current information on certain pages that contain CGI forms. The problem is that if I change the "action=" in the CGI form, the users browser still tries to execute the old action if the page isn't refreshed.

Thanks,
Chris
 
Javascript to refresh after 5 secs:

<script language=Javascript>
setTimeout(&quot;self.location.reload()&quot;, 5000);
</script>

HTML to do the same thing:

<meta http-equiv=&quot;Refresh&quot; content=&quot;5;URL=thispage.htm&quot;>

I doubt that you'll want to refresh while a user is working on a form.

Regards

-- taf
 
Will this refresh the page when they visit it, or will it refresh after 5 seconds of being on the page? I want the page to be current everytime they visit it, but I don't want it to refresh after they have already loaded the page.

Thanks,
Chris

ChrisP
RHCE, LPIC-1, CCNA, CNE, MCSE, +10 others
 
There's really no reliable way to clear a user's cache. Reloading generally won't work since it will just load the cached version again. Some people use the following in their header:
Code:
	<meta http-equiv=&quot;pragma&quot; content=&quot;no-cache&quot; /> 
	<meta http-equiv=&quot;Expires&quot; content=&quot;0&quot; />
But I wouldn't count on that, as I believe it is usually only interpreted by proxies, not individual browsers. The best thing to do is not update your pages too often, and only do it at non-peak times so that most people who enter your new page only do so on a new browser session. And don't be too quick to disable the old functionality so that you can handle people that hit different versions at the same time for a day or so.

Another thing to try is to add a sessionID or some other randomized string to your query string (eg:
Code:
[URL unfurl="true"]http://www.yoursite.com/form.html?sID=12345[/URL]
). When a browser sees this new URL, it likely won't try to load one with a different sID from cache. You can generate the sID on your first page and then insert it via JavaScript into all of your links via the onClick handler.

Sincerely,

Tom Anderson
Order amid Chaos, Inc.
 
sounds like you want to keep your pages from being cached. javascript cannot do this, but meta tags can:

<meta http-equiv=&quot;cache-control&quot; content=&quot;no-cache&quot;>
<meta http-equiv=&quot;pragma&quot; content=&quot;no-cache&quot;>
<meta http-equiv=&quot;expires&quot; content=&quot;-1&quot;>

however, javascript can be used to change the action of your forms. explain more what you mean by &quot;if I change the 'action=' in the CGI form, the users browser still tries to execute the old action if the page isn't refreshed.&quot;

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
I have a CGI form where &quot;action=/cgi-bin/script.cgi&quot;. After a certain date, I need to change the action= to something like &quot;action= so that a user doesn't try to execute the CGI script from that page anymore. If a user has that page cached, it will try to execute the old action, which is to launch the CGI script, when it should be redirected to the HTML page instead.

Thanks,
Chris
 
Chris,

Could you not get the CGI script detect if that date has passed, and if so, resubmit (using CGI) the form data to the new URL?

That way, it wouldn't matter if the page was still cached or not...

However, using the meta tags provided above, you shouldn't have any problem with cached files.

Dan
 
The meta tags worked, thanks.

I would have changed the CGI script to check to make sure that a date hasn't passed, but multiple forms all use the same script.

Thanks,
Chris

ChrisP
RHCE, LPIC-1, CCNA, CNE, MCSE, +10 others
 
..damn signature...I need to turn that off...

ChrisP
RHCE, LPIC-1, CCNA, CNE, MCSE, +10 others
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top