Completely remade the caching functionality.

Here's a completely new, and improved, implementation of the caching functionality. Extensively unit tested and acceptance tested, and without the issues that was plaguing the previous implementation. The code is also considerably easier to maintain the previous attempt. 

It is configurable in resource.properties whether or not to use the cache.