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
apakianAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VirusMinusCommented:
0
VirusMinusCommented:
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 -> http://www.experts-exchange.com/Web/Web_Languages/HTML/Q_10103831.html
0
apakianAuthor Commented:

> 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.

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

VirusMinusCommented:
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

0
VirusMinusCommented:
Here's someone who made progress doing it via XML

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20082233.html
0
apakianAuthor Commented:
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...

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

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20083788.html
0
VirusMinusCommented:
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
0
apakianAuthor Commented:


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.


0
VirusMinusCommented:
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?
0
apakianAuthor Commented:

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.


0
VirusMinusCommented:
I don't think there is a way to do what you want client side only. some initiation from the server is required.
0
apakianAuthor Commented:

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..



0
VirusMinusCommented:
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
0
apakianAuthor Commented:

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..


0
apakianAuthor Commented:

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 ?






0
VirusMinusCommented:
I wasn't so sure myself about the redraw, but i've found some more links (yes i searched for them , they're not bookmarks) I've learnt so much from researching this topic.

This excerpt is from this article http://www.sitepoint.com/print/php-anthology-2-5-caching which suggests that it is possible to not redraw the page based on a last-modified check

"Page Modification Time
---------------------------------
A more useful approach is to make use of the Last-Modified and If-Modified-Since headers, both of which are available in HTTP 1.0. Technically, this is known as performing a conditional GET; whether you return any content is based on the condition of the incoming If-Modified-Since request header.

Using this approach, you need to send a Last-Modified header every time your PHP script is accessed. The next time the browser requests the page, it sends an If-Modified-Since header containing a time; your script can then identify whether the page has been updated since the time provided. If it hasn't, your script sends an HTTP 304 status code to indicate that the page has not been modified, and exits before sending the body of the page.

Providing a simple example of conditional GETs is tricky, but PEAR::Cache_Lite is a handy tool to show how this works. Don't get confused though; this is not meant to show server side caching; it simply provides a file that's updated periodically.

Here's the code: "

Here's another excerpt from (read the discussions below as well) -> http://simon.incutio.com/archive/2003/06/21/caching
"The Expires header is a mixed blessing. If you are sure that your content will not change, or you are fine with people getting out of date objects, then by all means, go ahead. But what most people want is 'must-revalidate', which means that browsers/proxies can still cache the documents, but they need to validate their copy before presenting it to the end user. By 'validate', I mean "check it is up to date" (this is different to HTML validation).

To check that their copy is up to date, they can send a couple of extra headers when requesting the object. The server then has the freedom to send back a 304 Not Modified response. This is something that is done automatically by Apache for flat files (hence the appeal of "funky caching"). However, if you are generating your content via PHP, you have to explicitly code the check and response. "

some code was also posted here -> http://www.sitepoint.com/forums/showthread.php?threadid=114882

Another excerpt from this excellent article -> http://www.mnot.net/cache_docs/
"I’ve marked my pages as cacheable, but my browser keeps requesting them on every request. How do I force the cache to keep representations of them?

Caches aren’t required to keep a representation and reuse it; they’re only required to not keep or use them under some conditions. All caches make decisions about which representations to keep based upon their size, type (e.g., image vs. html), or by how much space they have left to keep local copies. Yours may not be considered worth keeping around, compared to more popular or larger representations.

Some caches do allow their administrators to prioritize what kinds of representations are kept, and some allow representations to be “pinned” in cache, so that they’re always available"

some more articles ->
http://www.httpsniffer.com/http/1302.htm
http://kavlon.org/index.php/website
http://www.zend.com/codex.php?id=435&single=1
http://www.webmasterworld.com/forum93/168.htm
http://www.phpbuilder.com/lists/phplib-dev-list/199911/0062.php
http://www.php.net/manual/en/function.session-cache-limiter.php
http://au.php.net/header
http://www.php.net/manual/en/function.session-cache-limiter.php

I quickly scanned these, but you may want to read them oin detail.


In summary it seems possible not to 'redraw' the page but refresh it only on modification (vague evidence), although you may have to choose from a variety of methods...

But you may have some flickering which may look like a redraw?

and yes we can still comminicate after you accept an answer. Email notifications continue unless someone unsubscribes from the question.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
apakianAuthor Commented:

this is going to keep me busy this weekend:

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

0
VirusMinusCommented:
Cheers!
-VM
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.