Kristian Lyngstøl's Blog

Saint Mode

Posted on 2009-08-24


Saint mode is now committed to trunk. This means you can evaluate responses in vcl_fetch and choose to discard them, hold off requests to the backend for N seconds and use graced objects instead. In other words, if your image-site is delivering images with http 200 OK but a single-digit content-length, you can decide to not use that response, but used the previously cached one instead (and/or try a different backend).

The syntax is reasonable simple. We've introduced the 'beresp.saintmode' variable which can be set in vcl_fetch. This adds the objecthead to a list of 'troubled' objects hanging off each backend. This means that if one backend is broken but an other is fine, only the broken one will be blacklisted for that specific object. After this is set, you need to restart. So something like this:

if (beresp.status == 500) { set beresp.saintmode = 20s; restart; }

Unfortunately we ran into a snag with regards to doing this in vcl_error, since we don't have what we need there. This is more of a general problem than saint mode-specific, and with PHK's blessings, I'll be writing a workaround/fix for this with regards to saintmode tomorrow. It should be reasonably simple to fix, if the VCL syntax is acceptable. (We're talking an hour or two + testing).