Do not repeat dirname function execution in writing cache files