December 30, 2004

Optimizing Web Application

For web applications, one neat way to minimize the use of server resources is to write all of your html's and js's in such a way that they can be cached in the end user's web browser. If you can separate static code from dynamic code, you can store the static code in a user's browser's cache. This way, the next time your user visit the site, your application gets loaded immediately without the need to request it from the server. However, there's one problem that you have to be aware of, and that is: if you do not develop a way to update cached version of your code, your users may be stuck with an old copy until they reset their browser's cache. One elegant solution to work around this is to tag the version of your code onto the name of your code file. Then, update the init/loading page, (i.e. index.html, default.aspx...), to point to the latest copy. In this way, if you have a newer version of the code, the browser immediately recognizes it. On the other hand, if your code hasn't changed, it will just be loaded from the cache. In addition, since we need the flexibility tell the browser which files to cache and which not, we would want to have a generic web application, e.g. cachefeeder.aspx, to feed our code to the browser, so that the http response header is properly set. Note that for small application, this technique should not be used because it reduces resource usage at the cost of simplicity and maintainability. Posted by david at December 30, 2004 10:03 AM | TrackBack
Comments