"Refactored" cache script.