How to refresh page ONCE onload?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Zafarana
    New Member
    • Mar 2007
    • 5

    How to refresh page ONCE onload?

    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!
  • DeMan
    Top Contributor
    • Nov 2006
    • 1799

    #2
    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.

    Comment

    • AricC
      Recognized Expert Top Contributor
      • Oct 2006
      • 1885

      #3
      Originally posted by Zafarana
      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:

      Code:
      <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

      Comment

      • kthequeen
        New Member
        • Dec 2007
        • 8

        #4
        I see how this works using

        Code:
        <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.

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          <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 ;)

          Comment

          • drhowarddrfine
            Recognized Expert Expert
            • Sep 2006
            • 7434

            #6
            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.

            Comment

            • clai83
              New Member
              • Dec 2007
              • 41

              #7
              Originally posted by drhowarddrfine
              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.

              Comment

              • drhowarddrfine
                Recognized Expert Expert
                • Sep 2006
                • 7434

                #8
                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.

                Comment

                • datnet01
                  New Member
                  • Jan 2008
                  • 1

                  #9
                  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!!! :-)

                  Comment

                  • muralig
                    New Member
                    • Feb 2008
                    • 1

                    #10
                    Thanks for the PHP solution! I know it's off-topic, but it worked great...

                    Comment

                    Working...