Jump to content

Force page refresh


Recommended Posts

Hello again Team!

I would like to know how to properly use the JS "reloadPage" function. I want to force a visitors browser to refresh when they enter my site so any changes I've made since their last visit will be what loads. I think this is the right function:

function reloadPage(){window.location.reload()}

What I need to know is...how do I call this function so that it only refreshes ONCE. I tried

<body onload="reloadPage">

but that makes it refresh continuously. Or do I have to tweak the function itself? I'm not that versed in JS yet, as you can tell. Thanks for any help forthcoming.

Link to comment
Share on other sites

I don't think you'll be able to use Javascript like this -- you will get a constant refresh.


You might want to do a Google search or two and see if there is a way to prevent your site from being cached, or asking the browser to check for newly updated files more often. I think there is a meta tag that can control page cache/when to check the cache, but I'm not sure.

Link to comment
Share on other sites

Again for me, the issue is you making decisions for your users. Many developers fall into the trap of thinking they know what is best for the user. Although you should be thinking how best to support your user, taking their choices away is not one of them.


Cache is clearly a choice of the user, it is built in to our browsers, we can choose top get the newest version or for speed run off our cache first. Now granted, the average user does not know what it is or how to change it, but that is there choice not to learn the possibilities of their browser. The choice is there, so it makes it there choice rather than ours.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...