Web programming question

karstenanderson

Senior member
Sep 8, 2004
919
0
76
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
 

cker

Member
Dec 19, 2005
175
0
0
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.
 

stndn

Golden Member
Mar 10, 2001
1,886
0
0
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.
 

karstenanderson

Senior member
Sep 8, 2004
919
0
76
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
 

stndn

Golden Member
Mar 10, 2001
1,886
0
0
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...
 

Cheetah8799

Diamond Member
Apr 12, 2001
4,508
0
76
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...