Skip to content

Commit aa7d9c3

Browse files
committed
docs: document cache size limit configuration options
1 parent 2360f2b commit aa7d9c3

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

docs/pages/image-caching.md

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,36 @@ To force a revalidation, you can either:
2020
3. change the [version number](/available-options#version) in the options (e.g. `version=2`)
2121
4. or flush the entire cache of your application using the `php artisan cache:clear` command.
2222

23+
## Cache Size Limit
24+
25+
The image caching feature also comes with a size limit to prevent the cache from growing indefinitely. The default maximum size is set to **100 MB**, but you can change this in the configuration file.
26+
27+
When the cache reaches the specified size limit, it will automatically clean up old files to make space for new ones.
28+
29+
You may also configure the percentage of the maximum size that should be kept after cleanup, referred to as `clear_to_percent`.
30+
For example, if `clear_to_percent` is set to 80, 20% of the cache is cleared on each cleanup run, and 80% is retained. The default is set to 80% of the maximum size.
31+
2332
---
2433

2534
You can configure the caching options in the `image-transform-url.php` configuration file:
2635

2736
```php
2837
/*
29-
|--------------------------------------------------------------------------
30-
| Image Cache
31-
|--------------------------------------------------------------------------
32-
|
33-
| Here you may configure the image cache settings. The cache is used to
34-
| store the transformed images for a certain amount of time. This is
35-
| useful to prevent reprocessing the same image multiple times.
36-
| The cache is stored in the configured cache disk.
37-
|
38-
*/
39-
40-
'cache' => [
41-
'enabled' => env('IMAGE_TRANSFORM_CACHE_ENABLED', true),
42-
'lifetime' => env('IMAGE_TRANSFORM_CACHE_LIFETIME', 60 * 24 * 7), // 7 days
43-
'disk' => env('IMAGE_TRANSFORM_CACHE_DISK', 'local'),
44-
],
38+
|--------------------------------------------------------------------------
39+
| Image Cache
40+
|--------------------------------------------------------------------------
41+
|
42+
| Here you may configure the image cache settings. The cache is used to
43+
| store the transformed images for a certain amount of time. This is
44+
| useful to prevent reprocessing the same image multiple times.
45+
| The cache is stored in the configured cache disk.
46+
|
47+
*/
48+
'cache' => [
49+
'enabled' => env('IMAGE_TRANSFORM_CACHE_ENABLED', true),
50+
'lifetime' => env('IMAGE_TRANSFORM_CACHE_LIFETIME', 60 * 24 * 7), // 7 days
51+
'disk' => env('IMAGE_TRANSFORM_CACHE_DISK', 'local'),
52+
'max_size_mb' => env('IMAGE_TRANSFORM_CACHE_MAX_SIZE_MB', 100), // 100 MB
53+
'clear_to_percent' => env('IMAGE_TRANSFORM_CACHE_CLEAR_TO_PERCENT', 80), // 80% of max size
54+
],
4555
```

0 commit comments

Comments
 (0)