My association website (http://www.nhoa.org.uk/) has pages that often need to be updated so that members can view the latest information (such as news and events). The problem is that members are still seeing the old page cached by the browser and don't realise that the page has been updated with new information. The address has web forwarding to the server at http://www.nhoa.hyperphp.com/home.html so even if they do refresh the page, with http://www.nhoa.org.uk/ in the address bar it always takes the reader back to the homepage without refreshing the page that was being read. To try and overcome this I've added a direct link under the menu to take the reader the server address so that pressing F5 refreshes the page being read without jumping to the homepage. This is far from ideal as members don't know when to click on the direct link and continue viewing the old cached data.
I need to implement a command in the coding to automatically refresh the page from the server address. I've been experimenting with <meta http-equiv="refresh" content="30"> but can't get it to work properly. If I set the content to "30" it waits 30 seconds before it's refreshed and the reader could have read the old data and gone by then. If I set it to less than that, say 10 seconds, it makes reading very difficult if they have a slow connection and the page keeps going off to reload every 10 seconds.
I ideally need something that will either force the browser to load the page from the server and not the cache (overriding the browser settings) or refresh the page once as soon as it has been loaded (or after a predetermined time) and then stop. Any suggests for achieving this will be greatly appreciated (I've done numerous searches online but everything seems to point to the above meta tag solution).
There are server-side ways to control caching, but I'm afraid that's not my forte. Do you have the impression this caching problem affects a lot of people? Do you see it yourself? If not, it could be that the users that have the problem have set their browsers to always cache.
Thanks Pandy. Yes it's a common problem and the majority of members aren't very computer literate. It has arisen again today with the Chairman unable to view a new page, hence me trying to resolve the problem again. The direct link didn't work for him so I'm having to try and explain to him how to delete his browser temp files. I also have the same problem when updating a page and I always have to refresh the direct link to check the published updates. When I added the new page I also couldn't see it online using Chrome, the direct refresh didn't work either and I had to delete the temp files before it would show.
I purchased the www.nhoa.org.uk/ address from 123-Reg over 10 years ago, it has been widely published and is well known to members so cannot be changed now. I don't know of a better way of setting it up using this address such that members don't get confused with another address appearing in the address bar. Is there a better way than cloaking? Any suggestions will be welcome.
When you tried reloading it were you viewing the homepage at http://www.nhoa.org.uk/? See what happens when you go to another page in the menu and then refresh it.
Well, when I write code to make an AJAX call I always include a query string with the time as the parameter. My hope is that this prevents cache problems.
Maybe you can add a 'time=' query string to the URL?
I already tried several pages. The same page reloaded when I refreshed.
The proper way to do it is to use a host where you can use your domain name as it's meant to be used. That is, from your registrar you point your domain to your hosts name servers. This is very easy. You get the names or IP addresses from your host and enter them in a form at your registrar. After a very short delay these days everything will work and you will be taken to your index file at your host when you type your domain name in the address bar.
This is how it works with paid hosts. There are some free hosts that offer domain hosting, but most don't. If I understand it right your current host offer domain hosting even with free accounts if I understand the spec right. The Learn More link doesn't work so...
Thanks Charles EF, I've never added a time query string in the URL. How does that work if I've published a domain name that people use?
Thanks Pandy but from what you're saying I'm sure that's how it works now. I bought the domain name from 123-Reg and in their control panel I point it to the server address at hyperphp.com. Its set up for framed web forwarding so that the user won't be confused by the change of address in the address bar. Maybe I shouldn't worry about that but if I use non-framed web forwarding will it overcome the problem without users having to manually refresh the page?
I think he means the frameset is reloaded with home.html in the frame instead of with the page you were viewing before.
I don't follow what you say about JS. Works fine for me with JS off and the only occurrence of "script" I find in the source is an empty NOSCRIPT.
Must be something wrong with your browser's JS toggling. Try viewing the page from http://www.rexswain.com/httpview.html (I get the JS from there too).
Wonder how the page is created. It seems to set a javascript cookie using JS-based AES encryption, but I don't know where the HTML comes from (maybe it's Ajax, but it also redirects to http://www.nhoa.hyperphp.com/home.html?i=1 --so maybe a server-side script checks if the cookie exists at that stage and only then outputs HTML).
No, it has always worked before. Must be something else. Maybe something the host is up to? The pages themselves seem like plain vanilla HTML. Peculiar.
It's peculiar to serve up JS (well, to some people) when JS isn't available and use no JS at all when it is.
Did you load it first with JS, then without? If so, maybe the page set a cookie with javascript first time, and then reads that cookie with a server-side script on subsequent visits, even if you've disabled JS by then.
This assumes that JS is served when no cookie is present, and HTML when there is a cookie.
Yes, of course I did. Could be it. Still, must be server side and I have a feeling it's the host doing it. There is no JavaScript used in the pages I looked at, just that empty NOSCRIPT.
Yes, you guessed right, I think. JS off and cookies deleted and I also get the stupid message.
Decky, do you have a free or paid account at that host? If free, have they at any point forced ads?
Goodness me there's a lot more going on here than I was ever aware of, thanks ever so much everyone for all the help.
I see about changing the internal URL, I could amend the address in the 123-reg panel that points to the server, I never thought of that. Thanks for the structure CharlesEF.
Yes ChritianJ, when the user loads the frameset using nhoa.org.uk, refreshing it takes them back to the homepage. The direct link to the server I added to the page was a way of bypassing the frameset so that refreshing the page only affects the page being read. Users won't know about refreshing frames and pages and they won't know when they'll need to refresh the page anyway.
It's a free host account Pandy and they had no forced ads when I set it up initially (and was advertised as such). They introduced them later though, I complained and they they took them off in exchange for me putting a link to their website on every page.
On a different note, I tend to go for simple solutions and I introduced some JS code in the header and single automatic updates now work perfectly. Now when I upload an updated page to the server it appears as soon as I click on the menu button again without having to refresh the page or delete any temp files. This should propagate out to members as soon as the old pages get cleared from their caches. The code modifies the URL in the address bar but it's invisible because it's cloaked and only shows http://www.nhoa.org.uk/.
<script type="text/javascript">
window.onload = function() {
if(!window.location.hash) {
window.location = window.location + '#loaded';
window.location.reload();
}
}
</script>
It does the job
OK, then I think it's your host that injects the JS crap. Their ads are probably JS dependent and they don't want anyone to miss them.
Theoretically it could also be your host that causes the caching problem. Pages can be cached on the server too, to preserve bandwidth I think. I don't know enough about this to find out if that's what's going on.
Maybe you should consider moving to another host? If you don't have many visitors a very small account (as accounts are usually huge today) would suffice and it shouldn't cost much at all. Then you would get rid of the JS and possibly the caching problem and fix the domain pointing all in one fell swoop.
Not sure if I follow Pandy, I don't have ads on the page any more, not for many years. I guess you mean that the JS could be a remnant from what the host put on in the old days.
I'm ok with the existing host, it's very reliable - I can't remember having any problems in the last 10 years (tempting fate) and the JS code I put on earlier (post #18) cures the caching problem. It may be plastering over the cracks but it does the job. I've removed the direct links to the server because the page won't need to be manually refreshed any more.
It's simple in that the alternative is to research other suitable hosting services, try and persuade Mr. Treasurer to pay for it by trying to explain what the benefits to the members will be (i.e. none), move all the files across and learn how to implement the site in an efficient and professional way. Or I could go with the simple solution and just keep the code as it is to automatically handle the page refreshes. I can't help thinking of the phrase, "if it works, don't fix it".
Exactly, I think the JS has to do with the ads.
Well, can you host your domain there for free?
I've used HyperPHP hosting service from when I first set the site up 10 years ago. It's always been a free account and it was ad-free in the beginning. They introduced ads later though and when I complained they took them off when I said I would put a link to their website on every page. They also provide free technical support which has been very good on the few times I've needed it (that's usually only provided on paid accounts).
So I can recommend them, it won't be worth moving to a paid account unless it's absolutely necessary and I can't see a reason why it would be (unless they change their policy).
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)