Efficient Reloads Using Active Server Pages
An efficient way of refreshing a page is reloading it only if it has some changes. These page may have over 20K of data and
reloading it every 5 seconds may consume important network resources uselessly. One way of avoiding this is having the
client watch out for data changes before updating the page. How do we do this?
We divide the page into two frames. One frame, the data frame, is for the page containg the data. The other, is for a page that
"listens" for changes on the data frame. This is the refresher page.
The refresher page contains only less than 1K and it will look something like this:
<HEAD>
<META HTTP-EQUIV="EXPIRES" CONTENT="2/5/99 11:30PM">
<META HTTP-EQUIV="REFRESH" CONTENT="2; URL='refresher.asp'">
</HEAD>
<%
If session("update")<>application("update") then
<script>
parent.data_frame.location="data_frame.asp"
session("update")=application("update")
</script>
end if
%>
The session("update") variable stores an information index on the data that is currently displayed on the client's browser.
The application("update") variable stores an information index on the most recent data on the server.
When the data on the server is changed (through another user) the
application("update") is incremented. When refresher page is refreshed and the session("update") is not the same as the application("update"), this means that the data frame is not to date. The refresher page then executes a script that updates the data frame.
In effect, the client browser retrieves less than 500 bytes every two seconds.
See an example of this technique in my MRV Message Board at the download area.
Email me at: big_marvin@hotmail.com
|