Hi,
brett wrote:
> I read in text files based on the page a user has reqeusted. The files
> are not larger than 10k. Sometimes I may read in two files for one
> page but the total read doesn't exceed 15k. However, I'm doing this on
> ever page load. After reading in the stream, I then do some parsing on
> each text file and display the content in a Label control.
>
> Is there a way to avoid doing the text file read and parsing on every
> page load? The content is fairly static but I would like a way to
> periodically refresh when something changes.
>
> Thanks,
> Brett
Depending on how your users use your web application, a reasonable
approach would be to load the files in the Session object, only when the
Session is initialized. To do this, simply check the Session object and
look for the files' content. If it is not found, load them. In normal
circumstances, a Session won't last very long (though that may really
vary depending on what your app does). This will ensure that every time
that a user loads your app in a new browser instance, the files' content
is newly loaded.
Should that not be good enough, you can check a timestamp, and every
time that a certain time runs, reload the file on the next call. For
example, load the file in the Session object, and set a timestamp. On
each request, check the timestamp. If the delay is longer than what you
decide, reload the files.
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering:
http://www.galasoft-LB.ch
Private/Malaysia:
http://mypage.bluewin.ch/lbugnion
Support children in Calcutta:
http://www.calcutta-espoir.ch