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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh when a visitor open a page!

Status
Not open for further replies.

grindange

Programmer
Jul 19, 2004
18
SE
Have a site with a information from a database. When I open the page from some PC:s they show me old info, since it's stored in the cache memory. The site need to be refreshed!

I know the statment - <META HTTP-EQUIV="REFRESH" CONTENT="20"> - but I just want that it should be refreshed once, when the visitor open the page, not every five or 20 seconds.

Any hints??

/ Marcus
 
You can use any of these and I think they will work. They block the cache-ing of that page. What your asking for is some javascript. If this is really what you want (not just blocking the cache) then I'll give ya the script.
Matt
 
whoops they didn't show up...I didn't put em in code tags
Code:
<meta name="robots" content="noarchive, noindex, nofollow, noimageindex, noimageclick">
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache-control" content="no-store">
sorry about that
 
This is very, very simple. It uses javscript. It will mess up if you already have a cookie on the page. Put this in your < head> tag.
Code:
<script>
if (document.cookie) {
//take this out if you don't want it to do anything
//if they've been here before
window.status=document.cookie;

}else {
//this is what happens if they've havent been here before

document.cookie='You have been here before'
this.reload();
}
</script>
 
grindage - properly, this information should be set in the HTTP header. This allows intermediary caches or proxies to know not to cache the page. (Jammer1221's method is for the client's browser cache)

Check the documentation for the web server you're using, and google for 'http cache headers'. Here's the W3C's HTTP Header specs.

<marc> i wonder what will happen if i press this...[ul][li]please tell us if our suggestion has helped[/li][li]need some help? faq581-3339[/li][/ul]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top