Move some code around in our cache handler for better parsing and accuracy of caching
Fix for issue #17