• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Web programming question

karstenanderson

Senior member
OK i'm pretty new to web programming. i've seen you can do a manual refresh even N seconds, but i'm looking for a more elegant solution. is what i'm asking even possible?

any way of checking the http return codes like 200-300 level stuff?

thanks..

karsten
 
I think the browser has to decide whether or not to pull down a page or use it from cache.

I'm not sure how to paste the HTML code in here, but you might use a meta tag - like these two, each inside the angle-brackets:

META HTTP-EQUIV="Pragma" CONTENT="no-cache"
META HTTP-EQUIV="Expires" CONTENT="-1"

Check out http://www.htmlgoodies.com/beyond/reference/article.php/3472881 for various methods of using the Cache-Control meta tag.

But there may be a way to do what you're suggesting; I just don't know any trick like that.
 
sorry, i'm just a little confused.

are you trying to tell the browser to reload from the server instead of cache when you open the page if the cache has expired?
or are you trying to tell the browser to load your page at certain time intervals?

http is a stateless protocol (or however it's called)
as such, there's no way to tell the browser to keep checking your cache every few minutes and compare it to the version in the server, unless you trick it by reloading the same page after certain period.
but then again, the browser will not be able to reload right at the same moment the server's file updates.

something like that.
 
yeah i was hoping for some kind of javascript that would auto-poll the server, compare the dates of index.html with the date of index.html in the browser's cache, and reload if necessary. would this be possible? right now i have it on a 24 hour expire in the meantime at least. thanks

karsten
 
Hmmm... maybe it's possible to be done using AJAX, but i wouldn't know since i have not used ajax before.
But from what I read, you can use it to communicate with the server without the user's interference, etc. And if you know enough about ajax, maybe you can figure out how to do what you're trying to accomplish.

other than that - i have no clue whatsoever...
 
Cached web pages are always a pain in the butt for web developers. There are a couple tricks. One is the meta tags in the header to say when the page expires. Most browsers will recognize this. Another is if you are doing PHP coding you can put some header tags in through PHP that will do the same thing.

I don't know of any javascript method because all browsers might handle it a little differently. Your javascript might have to have multiple blocks of code to run through depending on what browser is running it...


edit: after re-reading the original posting, it looks like you are more interested in a refresh button somewhere on the page for the user to press? You should be able to do that. Combined with the meta and header info I mentioned, as well as what others mentioned, you should be able to use both to ensure that it is in fact refreshing to the server every time.


One thing to note, if you are doing refreshes fairly quickly, and if your page does a lot of dynamic content and images, you are going to see a LOT more bandwidth and server CPU usage from your users...
 
Back
Top