Make the code that checks to see if the cache needs to be refreshed more efficient