Bug 870171 - Expire old data (2)

Note that this is built on #342 which must be pushed first.

Replaces #335 (for more history, see old comments there).