By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,493 Members | 1,936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,493 IT Pros & Developers. It's quick & easy.

How to refresh page ONCE onload?

P: 5
I've been searching on how to not get a cached version of my page. I've tried adding meta tags and even used an apparent 'cheat' by adding a second head after the body, this doesnt' work either. I do not want a timed refresh, rather, everytime someone goes onto the page it is the most recent version. Also added a function and called it onload but that just keeps going in an infinite loop. Can someone please help me? Much aprpeciated!
Mar 23 '07 #1
Share this Question
Share on Google+
9 Replies


DeMan
100+
P: 1,806
Hi (again) Zafarana,

Please direct techniacl questions to a specific forum. I think the answer you are looking for may be in an html tag, rather than JavaScript, so I'll pass you on to the HTML forum. I hope they can give you a sufficient answer.
Mar 23 '07 #2

Expert 100+
P: 1,892
I've been searching on how to not get a cached version of my page. I've tried adding meta tags and even used an apparent 'cheat' by adding a second head after the body, this doesnt' work either. I do not want a timed refresh, rather, everytime someone goes onto the page it is the most recent version. Also added a function and called it onload but that just keeps going in an infinite loop. Can someone please help me? Much aprpeciated!
Show me the meta tag you've tried. Have you tried:

Expand|Select|Wrap|Line Numbers
  1. <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  2.  
Mar 24 '07 #3

P: 8
I see how this works using

Expand|Select|Wrap|Line Numbers
  1. <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
but what would you do if you have a common header, include or master page, that you do not want the no-cache to be applied to? In other words I just want one specific page to refresh everytime on load but I am using a common header throughout the site and do want everypage to have this.
Dec 6 '07 #4

Markus
Expert 5K+
P: 6,050
<meta http-equiv="refresh" content="2; url=">

is that the sort of thing you want?

Content is the amount of seconds it takes untill the page is reloaded. url is, well i think you know what that is ;)
Dec 6 '07 #5

drhowarddrfine
Expert 5K+
P: 7,435
If you have access to your server settings, you can set the header to "expires" and the date. Or you can use the <meta>:
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 2008 08:21:57 GMT">

I'm not sure the meta version works anymore.
Dec 6 '07 #6

P: 41
If you have access to your server settings, you can set the header to "expires" and the date. Or you can use the <meta>:
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 2008 08:21:57 GMT">

I'm not sure the meta version works anymore.

If you are willing to do some PHP then here is some code that will help you

[PHP]
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
?>
[/PHP]

Put this code on the very top of your html page. Rename that page to .php extension.

!!!! Make sure that there are absolutely no spaces before the above snippet. If there are you will get an error.
Dec 7 '07 #7

drhowarddrfine
Expert 5K+
P: 7,435
PHP is off topic in the html/css forum. To offer a PHP solution to someone who may not even use PHP is not helpful either.
Dec 7 '07 #8

P: 1
Hi,

I just wanted to say THANKYOU for the PHP solution its exactly what i was looking for, as for the moderator who posted stating that he was not looking for a PHP solution and should not post here, well, it was never stipulated in his original post that he required only HTML and further more people looking for solutions are looking for just that, surely the same question shouldn;t be posted in each different topic depending on the language yuor using for the same problem!

Google returned my result and directed me here, any how, thanks again for the PHP!!! :-)
Jan 11 '08 #9

P: 1
Thanks for the PHP solution! I know it's off-topic, but it worked great...
Feb 29 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.