Introduce caching

This pull request introduces caching to the system. The caching can be set using the cachefile config parameter in config.ini - if unset caching is ignored. This reduces the number of requests that need to be made to the server.