Check the size of cache file
Remove duplicated code