Ilya Grigorik implements the stale-while-revalidate Cache-Control proposal with EventMachine and memcached:
The application logic is simple: if we have never seen this request, process, and cache it; if we've seen this request, and the cache is valid, then render response; if we've seen this response, but the cache is stale, render the stale version immediately, and then continue the process to update the cache. Also, to avoid the 'stampeding' effect, we've added a flag to mark a request as in-progress, to indicate that an application server is working on updating the cache.
Google announced on Monday a proposal for a new HTTP compression scheme, called Shared Dictionary Compression:
Over the last few weeks we've been experimenting with a way to get better compression for HTTP streams using a dictionary-based compression scheme, where a user agent obtains a site-specific dictionary that then allows pages on the site that have many common elements to be transmitted much more quickly.
Its Google group is here and includes the specification and a very helpful presentation. A quick search reveals that it is based on VCDIFF.
It works like this: the server notifies the client of the potential dictionaries a resource can be based off with a custom header that points to another resource in the server (Get-Dictionary). The client then downloads the dictionaries and on subsequent requests the client tells the server what local dictionaries it has stored locally (kinda like cookies). Then the server sends the resource expressed as a VCDIFF delta over one of the dictionaries the client has downloaded in the past.
Some comparisons could be drawn to fragment-based Ajax, since the VCDIFF delta is effectively the minimal expression of what has "changed" in the page with respect to the dictionary. But since it is implemented as a Content-Encoding at the HTTP level it degrades perfectly on non-Javascript clients and is useful for static content.
Good discussion on a strategy for autoexipiring memcached objects, based on the validity of their key:
The idea is to use memcached to store objects with keys that will automatically expire when the item changes.
You basically choose a key naming strategy that semantically loads the key with model data that is bound to be invalidated in the future. This way your code doesn't need to destroy or overwrite old memcached objects.
WebAlchemy is a very fast static cache for Django:
With WebAlchemy only pages involved in form processing are served directly by Django, the rest of the pages most of the time are served directly by Apache as static content with static content speed.
Basically it stores the request result in a static file and then creates an Apache .htaccess file to include a mod_rewrite rule with precedence over the dynamic mod_python call. In a recent post the author compares it with StaticGenerator, another, much simpler static cache with a similar static behavior but a different approach for marking and selecting cached requests.
The main problem with both of them is that only the response body is cached. Headers, and most importantly, the Content-Type header, are not preserved. It is Apache or the frontend server who decides what is the Content-Type for cached requests, by looking at the extension of the file and matching it to its configured MIME type database, and by properly configuring the valid index file name. For example StaticGenerator just names every cached request as index.html.
nginx 0.7.8 has been released with a new, interesting feature - a native XSLT module:
The module is filter that transforms XML using one or more XSLTs. The module requires libxml2/libxslt libraries.
Combined with the new $arg_param variable expansion for GET requests makes it a powerful enough feature to replace simple uses of PHP or other scripting languages.
