Thursday, September 29

Sub-page Caching Granularity

The <bigwig> project has a neat component that allows them to cache page fragments automatically on the client. The whole strategy is explained in
Language-Based Caching of Dynamically Generated HTML.

It boils down to translating pieces of the templates (templates are written in a domain-specific language) into individual JavaScript files. These files represent static structure (albeit with “gaps,” places where dynamic content will be inserted) and can be safely cached by the browser without worrying about stale content.

Each page of the web application is simply a “string pool,” a list of the bits of dynamic content, and instructions on how to combine template pieces into the final page. All assembly is done client-side with JavaScript.

I think this is a pretty cool idea. It’s also probably a bit of overkill, given the problem. It also has some nasty consequences: no searchability, no view source, and a requirement on JavaScript.