Implement new blob caching algorithm and fix tests.