Link to home
Start Free TrialLog in
Avatar of apakian
apakianFlag for Australia

asked on

html refresh once again


i bet my life this has been asked a hundred times, so my apologies.

how can i make the web browser, check if a html page has been modified and make sure
the user is viewing the latest version.

i' am not refering to a simple meta-refresh or expires,,  is there a way to make the browser
check and compare the last modified time of the html file say every 60 seconds,, but not
refresh the display ( as this produces flicker ) if the html file is unchanged..

thankyou

ashod apakian
Avatar of VirusMinus
VirusMinus
Flag of Australia image

If you can use ASP this is a nice way to do it ->
<%
'prevent any cache issues occuring by putting this at the top of the page
Response.Expiresabsolute = Now() - 1
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"  
Response.AddHeader "cache-control","private"
%>

Some more info here -> https://www.experts-exchange.com/questions/10103831/Refresh-an-HTML-page.html
Avatar of apakian

ASKER


> am not refering to a simple meta-refresh or expires,,  is there a way to make the browser
> check and compare the last modified time of the html file say every 60 seconds,, but not
> refresh the display ( as this produces flicker ) if the html file is unchanged..

example:

somedays i update my index.html once a day,, and on some days i update once every 10 minutes..

i want the following

1) users opens IE, and goes to htp://www.mysite.com/index.html
2) browser gets index.html , displays it to the user and stores it in its cache
3) somehow index.html tells the browser, to check if it has been modified every X seconds
4) every X seconds, the browser checks if index.html has been, if its been modified goto step 2
5) reset timer, goto step 4

most important thing is, if the page has not been modified, i dont want to browser to refresh the
display..

setting the meta-refresh to say 30,, will cause the page to reload every 30 seconds, regardless,
which is annoying.. i just want a reload only when the page has been updated.

i think this what you're trying to do but via script ->

In IE:
1. Click Tools, then Options
2. Under the General tab, click 'Settings'
3. Click the radio button next to "Every visit to the page"

Other browsers have similar settings.

To do this via script you need wither applets or XML, there maybe other ways but they can be more complicatd to implement. You're looking for the server to intitate the refresh. This is called a Server Push..

Here are some links about the same ->
http://www.15seconds.com/issue/971102.htm
http://www.antipope.org/charlie/attic/webbook/ch3http/part7.html
http://wp.netscape.com/assist/net_sites/pushpull.html
http://www.cs.sfu.ca/CourseCentral/365/li/material/slides/A21.html
http://www.via.ecp.fr/~vbp/test/serverpushvbp.html
http://webclass.csuchico.edu/courses/advweb/notes/server-push/index

Avatar of apakian

ASKER

In IE:
1. Click Tools, then Options
2. Under the General tab, click 'Settings'
3. Click the radio button next to "Every visit to the page"

Other browsers have similar settings.

this is an setting of the browser..........

please look at point 3)


>> 3) somehow index.html tells the browser, to check if it has been modified every X seconds

it would be completely impracticle to send an email out to all our users suggesting they
set some setting their browser.

explaining a problem is not my strong point :-)

in a nutshell, i want the browser to only re-download and re-display a html page only when it's last
modified field differs from the last modified field in it's cache...

ok there seems to be a way, read this Q and try the javascript;

https://www.experts-exchange.com/questions/20083788/smartest-way-of-a-client-refresh.html
I understood your problem, I mentioned that the IE setting is what you want to emulate but via code. Read my posts and follow the links. The way to do it seems to be via applets, XML or a javascript function.

-VM
Avatar of apakian

ASKER



i understamd, but Q_00083788.html refers to

"using reload is the same call, except reload will load from cache unless the page has the page cache disabled."

the cache issue is not my primary concern:

using 'c' code , i can write a small function that sits in a loop and calls a GET to a particular url every
X seconds, with the field If-Modified-Since: Nov 05 ......

assuming im a browser , if i get a 304 then  i do nothing,, and i do not refresh the users page,
if i do get a 200, then i get the lasted copy, refresh the users page update the lastmodified to
what the lastmodified was of the latest file i just downloaded and start the whole loop again.


Found this pdf, is interesting.

http://www.bluecoat.com/downloads/files/BCS_create_cachefriendly_website.pdf

Also, do you have control of the webserver where your web pages will be hosted? Do you know what webserver is running? IIS or something else?
Avatar of apakian

ASKER


is i have a dedicated server at servermatrix, with root access, there is no firewall or proxy, they
just give me an ip..

for web, im using apache 2 ( i think there is perl and fastcgi installed ), but i need
to achieve the solution, by client-side coding, as some of our pages will be served
from other server not-owned by us.


I don't think there is a way to do what you want client side only. some initiation from the server is required.
Avatar of apakian

ASKER


firstly,, that pdf.link is very very good..

where do you see any initiation from the server...

the psuedo-code i've supplied is completely stateless, excluding local timers on
the client-side, which are obviously implemented in the javascript or html handlers.

i dont know 'html' or 'javascript', but ive written http servers and clients in c.

a http client ( the web browser ), periodically connects to the http server, and
requests a file to be downloaded if the lastmodified fields differ..

the http server, sits in a loop forever waiting for http clients to connect to it.

i see no initiation from the server, in my question.. can you please clarify..



Okay i think I understand now, The last-modified header could be used to do what you want. Fortunately Apache supports reading of this header i think. refer ->
http://www.web-caching.com/mnot_tutorial/notes.html
http://httpd.apache.org/docs/mod/mod_expires.html
http://www.mit.edu/~yandros/doc/cache_doc.html
http://www.html-faq.com/serverbasics/?caching
Avatar of apakian

ASKER


im reading them now,, the documents

http://www.web-caching.com/mnot_tutorial/notes.html
http://httpd.apache.org/docs/mod/mod_expires.html

are issues covering server side, so those solutions are  redundant.
the other 2 documents, like the first look very written, concerning
caching ( i'd really like a copy of your bookmarks )..

i will quickly jot through them, but ive got a feeling it's
not quiet what i want,, brb..


Avatar of apakian

ASKER


http://www.mit.edu/~yandros/doc/cache_doc.html

gave me the answer, in a few steps more than anticipated...

i think if i use

Cache-Control: max-age=60, must-revalidate

every 60 seconds it will force the browser to check if the file has been modified,, i am
assuming and hoping that if it has NOT, then the web browser will result the timer
and check again after another 60 seconds; this solves the main problem.. thankyou..

however, i do not know if this happens at the presentation layer or the transport layer:
the reason i mention this; is if this solution is at the presentation/html layer, than
i am certain, it will cause the display to be refreshed even if the file has not changed,
 ( display refreshed meaning, just redraw the one from the cache )...

can i prevent this,, as even though more a cosmetic and issue, it would wrap
this problem up for me, if i can restrict the refreshing of the page when and only
if the page has been modified..

if i acccept your answer now, can we still communicate ?






ASKER CERTIFIED SOLUTION
Avatar of VirusMinus
VirusMinus
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of apakian

ASKER


this is going to keep me busy this weekend:

my hat of to you, thankyou for the great info..

Cheers!
-VM