Cache maintenance
Generated files stay on the disk forever; nothing expires them. Remove them when sources or presets change, and check them after crashes.
Clearing the cache
Section titled “Clearing the cache”php artisan imagepresets:clearphp artisan imagepresets:clear --tempphp artisan imagepresets:clear --disk=s3 --path=imagepresetsDeletes the path directory on the disk (both default to the config values). --temp also empties source_dir and temp_dir — downloaded remote sources and Glide leftovers.
Files are regenerated on the next request. Purge the CDN / nginx cache as well — see HTTP caching.
Verifying cached files
Section titled “Verifying cached files”A worker killed during encoding (OOM, deploy restart) can leave a broken image that would then be served with year-long cache headers. Since 1.17 the package writes to a temporary file, checks it and renames it atomically, so this should no longer happen for new files. imagepresets:verify finds what is already broken:
php artisan imagepresets:verify # list onlyphp artisan imagepresets:verify --delete # delete corrupted files and old *.tmp* leftoversphp artisan imagepresets:verify --deep # also decode every webpphp artisan imagepresets:verify --deep --gray-threshold=40php artisan imagepresets:verify --delete-suspectsWhat it reports:
- Corrupted — truncated files: JPEG without the end marker, PNG without
IEND, GIF without the trailer, WebP whose RIFF size doesn’t match the file size; for AVIF, a filegetimagesize()can’t read. - Orphaned tmp —
*.tmp*files older than one hour, left by processes killed before the rename. - Suspect webp (
--deep) — WebP files that decode, but where more than--gray-thresholdpercent (default 25) of a 12×12 grid of sampled pixels is exactlyrgb(128,128,128). That is what libwebp paints where the payload is damaged although the container size is right.
Suspects are a heuristic: an image with large flat gray areas is a false positive. --delete never touches them; review the list and use --delete-suspects (it implies --deep).
Deleted files are regenerated on the next request — purge them from the CDN too.
Verify decode at generation time
Section titled “Verify decode at generation time”IMAGEPRESET_VERIFY_DECODE=trueRuns the same gray-filler check on every newly generated WebP (threshold 25 %) before it reaches the cache. A rejected image is not stored, the request returns 404 and the next request tries again. Costs a few milliseconds per generation, once per file. Same false-positive caveat as above — that is why it’s off by default.
Temporary directories
Section titled “Temporary directories”| Directory | Contents | Cleaned |
|---|---|---|
source_dir | Working copy of the source during generation; downloaded remote sources (dl_*) | Working copies after each generation; dl_* only when a new image is generated — see Image sources |
temp_dir | Glide’s temporary files | By Glide |
local_cache_dir | Results waiting for upload to a remote disk | After a successful upload |
imagepresets:clear --temp empties source_dir and temp_dir. Don’t run it while images are being generated — it can remove a working copy mid-generation (that request returns 404).