tmarois
tmarois

Reputation: 2470

Laravel storing many gigabytes of cache storage files and does not automatically erase old cache

I'm using Laravel 5.8.12

I am noticing that laravel /storage is saving over 10gb of cache storage. And doesn't seem to clear up.

But why is it constantly building cached files? Isn't there suppose to be a garbage collector or automated cache clear/replace.

This does not seem sustainable.

To confirm, all of this data is being stored in /storage/framework/cache

I have not changed the default settings in the cache config.

Yes, I know I can create my own cache clear script, but the point is, why is it doing this and how do I prevent it from happening. It will take the remaining disk space on the server...

Upvotes: 6

Views: 5289

Answers (2)

zoryamba
zoryamba

Reputation: 345

Some cache storages, such as memcached or redis, implements TTL feature on their own, so you don't have to clear timed out cache. So I think, due to SRP and ISP, cache driver shouldn't be in charge of clearing old cache.

But I sure it MUST be at least mentioned in cache docs and I don't have answer to question "why it isn't".

Upvotes: 2

Mehrdad Shokri
Mehrdad Shokri

Reputation: 2134

Periodically cleaning cache needs some further efforts. You need to set up a cron job with systemd or whatever cron job runner you're comfortable with.
Then run php artisan cache:clear in the job.
reference

Upvotes: 4

Related Questions