Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q306 Is there anyway to force the browser to reload the html page from the server and not from the browsers cache?

irt.org | Knowledge Base | JavaScript | Redirect | Q306 [ previous next ]

Q306 Is there anyway to force the browser to reload the html page from the server and not from the browsers cache?

<script language="JavaScript"><!--
if (document.images)
    location.reload(true); // forces a reload from the server
else
    location.href = location.href;  // just reloads the page
//--></script>

Although this will continually reload the page if it is less as shown. What is needed, is a test to see if the page has already been reloaded (perhaps in the last second):

<script language="JavaScript"><!--
function forceReload() {
    if (document.images)
        location.replace(location.href + '?' + (new Date()).getTime());
    else
        location.href = location.href + '?' + (new Date()).getTime();
}

var lastTime = location.search.substring(1) - 0;
if ((new Date()).getTime() - lastTime > 1000)
  forceReload();
//--></script>

Feedback on 'Q306 Is there anyway to force the browser to reload the html page from the server and not from the browsers cache?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.