Jump to content
Killersites Community
Sign in to follow this  
Woody

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.

Share this post


Link to post
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.

Share this post


Link to post
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.

 

Cheers

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×