Lee
Lee

Reputation: 3969

can typical browser based web solutions utilise caching?

Given a typical web application that may be implemented in a "server side" language, such as the ASP.NET collection or PHP, with a browser providing the end-user interaction is it possible to make use of a persistent local cache?

For instance, take a simple centralised database storing thousands of staff records. It would be more efficient for the browser to have a local copy of the appropriate data as long as this cache doesn't become stale. How would this be accomplished? As far as I'm aware cookies are the extend of exposed browser memory and strict domain policy stops any interaction with the hard drive.

I'm thinking from a PHP or ASPX web form application (hypertext application?) perspective which I understand as stateless so I'm having difficulty understanding how this would be achieved. Would other .NET solutions offer any advantage, like .NET MVC or WCF?

I should make a note that this is not considering the applet technologies Java, Flash, Silverlight et al.

Upvotes: 1

Views: 89

Answers (1)

King Friday
King Friday

Reputation: 26106

HTML5 localStorage and sessionStorage can house up to 5 MB or more depending on the browser for a domain.

HTML5 ApplicationCache in particular is good for what you want as you can specify a manifest that is checked for modifications each request but only that file is accessed every time while your cached resources will not be requested unless directed to do so, saving tons of bandwidth. If you served the manifest file via server-side dynamic programming, you could easily implement a caching strategy by simply changing the manifest file timestamp or comment within the doc as you get new data in. The manifest file could be dynamically served based on a user's cookie so you could in affect have sets of data that you have per user if you needed to compartmentalize the data.

You would have to develop heavy on the JavaScript client-side with JSON.stringify and jQuery.parseJSON to serialize and deserialized using some framework like knockout.js for the databinding etc. I have extensive experience doing these kinds of things and used to think server-side so much. Now I only see the server-side allowing me to CRUD JSON data as that's what I use it for when doing web apps.

Upvotes: 4

Related Questions