Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jdavidbakr's avatar

File Cache Driver Garbage Collection

I am using the file driver for cache, and there are several entries that the key only is good for a short time (we're talking 24 hours). My question is, is there any kind of garbage collection that happens to clean up the files, or am I responsible for this myself? I can't seem to find anything in the docs about this or what the best practices would be if I need to clean them up myself - I'm thinking maybe a cron job running something like:

find [path-to-cache]/. -type f -atime +1 -execdir rm {} \;

to purge any cache files that have not been accessed in the last 24 hours.

Alternatively we could run an artisan cache:clear command every 24 hours, but ideally I'd like to not reset the cache every day.

Any thoughts or is there any documentation on the best practices to keep your cache file directory from growing too large?

0 likes
1 reply

Please or to participate in this conversation.