Query cache: add support for writing precomputed queries.

Precomputed queries are ones that get generated by a batch job of some
sort as opposed to being updated in-place.  These queries have a
slightly different (and more complicated) write path that wasn't yet
implemented.
Query cache: fix reading of precomputed queries.

The index mangled keys weren't being accounted for properly, this allows
precomputed queries to be properly read.

The dangers of writing code that isn't actually in use. :(
Factor out NSFW stamp to utils.html.