Move some code around in our cache handler for better parsing and accuracy of caching