webp-sh / webp_server_go

Go version of WebP Server. A tool that will serve your JPG/PNG/BMP/SVGs as WebP/AVIF format with compression, on-the-fly.
https://docs.webp.sh
GNU General Public License v3.0
1.79k stars 174 forks source link

Delete older files from storage #282

Closed Zaied closed 11 months ago

Zaied commented 11 months ago

We have been using this service for one of our projects for a while. But the problem storage often gets full and we get errors on the client side. We tried to run a cron job to run the command rm/rf to clean all older files but the issue is clearing too many files shows an error that arguments are too long.

Any way around to solve it?

n0vad3v commented 11 months ago

Thanks for feedback, currently you can have a try using find, example:

0 0 * * * find /path/to/your/webp/exhaust/ -type f -ctime +1 -exec rm {} \;

Related issue: https://github.com/webp-sh/webp_server_go/issues/214

n0vad3v commented 2 months ago

Hi @Zaied ,We've released version 0.12.0 which contains a configuration called MAX_CACHE_SIZE that will automatically clean local files if local cache directories' size are larger than setting value, please give it a shot if you're interested. 😇 https://github.com/webp-sh/webp_server_go/releases/tag/0.12.0

Documentation: https://docs.webp.sh/usage/configuration/