Caching Web 2.0
Tuesday, 16 May 2006
I just finished my XTech presentation, “ Web 2.0 on Speed”. here are the slides [pdf]; I’m going to try to s5 them soon. There isn’t much new in this talk; it’s just a synthesis of a few different observations;
1. Static Web servers are fast.
You might say ‘duh’, but people often overlook the obvious; with event-looped Web servers like lighttpd (see c10k for more information), you can get 2-3 orders of magnitude more requests/second over LAMP and similar applications.
2. Web Caches can help distribute applications.
Because they’re easier to deploy as reverse proxies, and on virtually every browser. However, many developers fear them, because they can’t control them, or don’t trust how they’ll behave. This can be addressed by quantifying their behaviour and by educating users on how to control them (e.g., cache-control: private).
3. A little bit of AJAX spice goes a long way.
Using JavaScript to extend HTML allows the addition of a few small capabilities to browsers that make a big difference to caching. In particular, I made public three libraries I’ve been working on;
- HInclude
- hinclude.js allows you to compose dynamic pages within browsers. We wanted to do it this way when we did ESI, AJAX makes it possible now. See also Micah’s paper [pdf] quantifying the benefits of this approach.
- URL Templating
- url_template.js allows you to interpolate variables into URLs, making it possible to load personalisation data from a separate file and use that to customise the page presentation. I expect that this will expand to incorporate other functions like looping, conditionals, etc. based on loaded preferences in time.
- JSON Form Submission
- json_form.js sniffs for HTML forms with an enctype of “application/json” and sends the form data as JSON rather than url-encoding it. N.B.; Safari and Opera will not support PUTting forms, and I haven’t debugged it on IE yet; it will be fixed and documented ASAP.
As I said in my talk, I’m not necessarily pushing these as libraries that should be standardised upon (although I’ve been using HInclude on almost every page of mnot.net with no complaints for the past three months). What I would like to see is for common JS functions like this to be sifted out and standardised as declarative markup, so that they’re more semantically transparent, and less of a security issue.
What’s Next?
I think the real interesting work is going to come in extending the caching model, to allow things like credential caching, advanced invalidation, and even offline operation. Stay tuned.
7 Comments
Laurens Holst said:
Wednesday, May 17 2006 at 1:40 AM
Mark Nottingham said:
Wednesday, May 17 2006 at 3:12 AM
James Stewart said:
Wednesday, May 17 2006 at 7:51 AM
Arien said:
Wednesday, May 17 2006 at 11:38 AM
Aristotle Pagaltzis said:
Thursday, May 25 2006 at 10:40 AM
Mark Nottingham said:
Wednesday, June 21 2006 at 11:11 AM
Mark Birbeck said:
Tuesday, July 18 2006 at 7:48 AM