Skip to content

Commit 839b176

Browse files
committed
Grammarly, fixed classification, addressed PR comments
1 parent 7116b34 commit 839b176

18 files changed

+707
-144
lines changed

docs/cache/external.mdx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ Most major CDNs (Cloudflare, Fastly, AWS CloudFront, Akamai, etc.) can cache img
1212

1313
### Recommended CDN settings
1414

15-
* **Origin shield** - Add a secondary cache layer between your CDN and imgproxy origin
1615
* **Image optimization** - Disable CDN image optimization to avoid double-processing
17-
* **Compression** - Enable gzip/Brotli compression for bandwidth savings
18-
* **HTTP/2 Server Push** - Push critical images to reduce latency
16+
* **Compression** - In case your CDN supports conditional compression of SVG images, enable gzip/Brotli compression for bandwidth savings
17+
* **Include essential headers*** - It's strongly recommended to include `Accept` header in the cache key. If you have client hints enabled, include also `DPR`, `Sec-CH-Dpr`, and `Sec-CH-Width` headers.
18+
* **Origin shield** - Add a secondary cache layer between your CDN and imgproxy origin if your CDN supports it.
1919

2020
## nginx caching
2121

@@ -32,16 +32,24 @@ server {
3232
listen 80;
3333
server_name images.example.com;
3434
35-
# Include request and feature signals that can change imgproxy output
36-
proxy_cache_key "$scheme$request_method$host$request_uri:accept=$http_accept:dpr=$http_dpr:width=$http_width:chdpr=$http_sec_ch_dpr:chwidth=$http_sec_ch_width";
35+
# Uncomment if you do not use format negotiation and client hints
36+
# proxy_cache_key "$scheme$proxy_host$request_uri";
37+
38+
# Uncomment if you use format negotiation
39+
# proxy_cache_key "$scheme$proxy_host$request_uri$http_accept";
40+
41+
# Uncomment if you use client hints
42+
# proxy_cache_key "$scheme$request_method$host$request_uri:dpr=$http_dpr:width=$http_width:chdpr=$http_sec_ch_dpr:chwidth=$http_sec_ch_width";
43+
44+
# Uncomment if you use format negotiation and client hints
45+
# proxy_cache_key "$scheme$request_method$host$request_uri:accept=$http_accept:dpr=$http_dpr:width=$http_width:chdpr=$http_sec_ch_dpr:chwidth=$http_sec_ch_width";
3746
3847
location / {
3948
proxy_pass http://imgproxy;
4049
4150
# Cache configuration
4251
proxy_cache imgproxy_cache;
43-
proxy_cache_valid 200 24h;
44-
proxy_cache_valid 304 24h;
52+
proxy_cache_valid 200 30d;
4553
proxy_cache_valid 404 1m;
4654
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
4755
proxy_cache_background_update on;
@@ -65,7 +73,7 @@ The exact key depends on which imgproxy features can change output for the same
6573
proxy_cache_key "$scheme$proxy_host$request_uri";
6674
```
6775

68-
2. Include format negotiation signal when WebP/AVIF/JXL preference can vary by client:
76+
2. Include [format negotiation](../configuration/options.mdx#avifwebpjpeg-xl-support-detection) signal when WebP/AVIF/JXL preference can vary by client:
6977

7078
```nginx
7179
proxy_cache_key "$scheme$proxy_host$request_uri$http_accept";
@@ -82,7 +90,7 @@ Use the smallest key that still prevents collisions for your traffic profile.
8290
### Key recommendations
8391

8492
* Include `Accept` in the cache key if format negotiation is used.
85-
* Include DPR/width-related hints in the cache key if Client Hints are used to vary output.
93+
* Include DPR/width-related hints in the cache key if [Client Hints](../configuration/options.mdx#client-hints-support) are used to vary output.
8694
* Set long `inactive` timeout (30d) to keep popular images in cache.
8795
* Configure `proxy_cache_use_stale` for graceful degradation during origin issues.
8896
* Monitor `/proc/sys/fs/file-max` and increase if needed for large caches.
@@ -163,10 +171,10 @@ sub vcl_hash {
163171
}
164172
165173
sub vcl_backend_response {
166-
# Cache successful responses for 24 hours
174+
# Cache successful responses for 30 days
167175
if (beresp.status == 200) {
168-
set beresp.ttl = 24h;
169-
set beresp.keep = 24h;
176+
set beresp.ttl = 30d;
177+
set beresp.keep = 30d;
170178
}
171179
172180
# Cache 404s for a short period

docs/cache/internal.mdx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,3 @@ When a request comes in:
6666
3. imgproxy checks if a cached image exists in the configured storage.
6767
4. If the cached image exists and is valid, imgproxy serves it directly.
6868
5. If not, imgproxy processes the image and stores the result in the cache before serving it.
69-
70-
## Monitoring
71-
72-
Monitor cache performance with metrics:
73-
74-
* Cache hit rate
75-
* Cache size
76-
* Cache evictions
77-
* Cache latency
78-
79-
These metrics are available through [monitoring endpoints](../monitoring/prometheus.mdx).

docs/cache/internal/amazon_s3.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ imgproxy can store cached images in Amazon S3 buckets or S3-compatible storage.
88

99
1. Set the `IMGPROXY_CACHE_USE` environment variable to `s3`.
1010
2. [Set up the necessary credentials](#set-up-credentials) to grant access to your cache bucket.
11-
3. _(optional)_ Specify the AWS region with `IMGPROXY_CACHE_S3_REGION`. Default: `us-west-1`
12-
4. _(optional)_ Specify the cache bucket name with `IMGPROXY_CACHE_BUCKET`.
11+
3. Specify the cache bucket name with `IMGPROXY_CACHE_BUCKET`.
12+
4. _(optional)_ Specify the AWS region with `IMGPROXY_CACHE_S3_REGION` or `AWS_REGION`. Default: `us-west-1`
1313
5. _(optional)_ Specify the S3 endpoint with `IMGPROXY_CACHE_S3_ENDPOINT`. You can also set `IMGPROXY_CACHE_S3_ENDPOINT_USE_PATH_STYLE=false` to use the virtual host style for the endpoint.
1414
6. _(optional)_ Specify the AWS IAM Role to Assume with `IMGPROXY_CACHE_S3_ASSUME_ROLE_ARN`.
1515
7. _(optional)_ Specify the External ID to pass to the AWS IAM Role when assuming it using `IMGPROXY_CACHE_S3_ASSUME_ROLE_EXTERNAL_ID`. This will have no effect if the assume role ARN is not specified.

docs/cache/internal/azure_blob_storage.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ imgproxy can store cached images in Azure Blob Storage containers. To use Azure
99
1. Set the `IMGPROXY_CACHE_USE` environment variable to `abs`.
1010
2. Set `IMGPROXY_CACHE_ABS_NAME` to your Azure account name.
1111
3. [Set up the necessary credentials](#set-up-credentials).
12-
4. _(optional)_ Specify the cache container name with `IMGPROXY_CACHE_BUCKET`.
12+
4. Specify the cache container name with `IMGPROXY_CACHE_BUCKET`.
1313
5. _(optional)_ Specify the Azure Blob Storage endpoint with `IMGPROXY_CACHE_ABS_ENDPOINT`.
1414

1515
### Configuration

docs/cache/internal/google_cloud_storage.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ imgproxy can store cached images in Google Cloud Storage buckets. To use the GCS
88

99
1. Set the `IMGPROXY_CACHE_USE` environment variable to `gcs`.
1010
2. [Set up credentials](#setup-credentials) to grant access to your cache bucket.
11-
3. _(optional)_ Specify the cache bucket name with `IMGPROXY_CACHE_BUCKET`.
11+
3. Specify the cache bucket name with `IMGPROXY_CACHE_BUCKET`.
1212
4. _(optional)_ Specify the Google Cloud Storage endpoint with `IMGPROXY_CACHE_GCS_ENDPOINT`.
1313

1414
### Configuration

docs/cache/internal/local_filesystem.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: Learn about how to configure the local filesystem cache in imgproxy
66

77
imgproxy can store cached images on the local filesystem. To use filesystem cache, do the following:
88

9-
1. Set the `IMGPROXY_CACHE_USE` environment variable to the filesystem.
9+
1. Set the `IMGPROXY_CACHE_USE` environment variable to `fs`.
1010
2. Set `IMGPROXY_CACHE_LOCAL_FILESYSTEM_ROOT` to your cache directory path.
1111
3. _(optional)_ Specify a path prefix for cache files with `IMGPROXY_CACHE_PATH_PREFIX`.
1212

@@ -25,5 +25,5 @@ imgproxy can store cached images on the local filesystem. To use filesystem cach
2525
Assume you want to cache processed images in `/var/cache/imgproxy`. Run imgproxy with `IMGPROXY_CACHE_LOCAL_FILESYSTEM_ROOT` set to your cache directory:
2626

2727
```bash
28-
IMGPROXY_CACHE_USE=filesystem IMGPROXY_CACHE_LOCAL_FILESYSTEM_ROOT=/var/cache/imgproxy imgproxy
28+
IMGPROXY_CACHE_USE=fs IMGPROXY_CACHE_LOCAL_FILESYSTEM_ROOT=/var/cache/imgproxy imgproxy
2929
```

docs/cache/internal/openstack_swift.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ imgproxy can store cached images in OpenStack Object Storage, also known as Swif
1515
* `IMGPROXY_CACHE_SWIFT_TENANT`: the tenant name for cache (optional, v2 auth only). Default: blank
1616
* `IMGPROXY_CACHE_SWIFT_DOMAIN`: the Swift domain name for cache (optional, v3 auth only). Default: blank
1717

18-
3. _(optional)_ Specify the cache container name with `IMGPROXY_CACHE_BUCKET`.
18+
3. Specify the cache container name with `IMGPROXY_CACHE_BUCKET`.
1919

2020
### Configuration
2121

docs/configuration/options.mdx

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
4848
* [`IMGPROXY_PATH_PREFIX`]: the URL path prefix. Example: when set to `/abc/def`, the imgproxy URL will be `/abc/def/%signature/%processing_options/%source_url`. Default: blank
4949
* [`IMGPROXY_USER_AGENT`]: the User-Agent header that will be sent with the source image request. You can use the `%current_version` variable to insert the current imgproxy version. Default: `imgproxy/%current_version`
5050
* [`IMGPROXY_USE_ETAG`]: when set to `true`, enables using the [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) HTTP header for HTTP cache control. Default: `false`
51-
* [`IMGPROXY_ETAG_BUSTER`]: a global ETag buster value. Change it to invalidate old ETags and prevent `304 Not Modified` responses for stale client/CDN validators. Default: blank
51+
* [`IMGPROXY_ETAG_BUSTER`]: a global ETag buster value. Change this value if you update configuration that affects image processing, to invalidate old ETags and avoid `304 Not Modified` responses from stale client/CDN validators. Default: blank
5252
* [`IMGPROXY_USE_LAST_MODIFIED`]: when set to `true`, enables using the [Last-Modified](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified) HTTP header for HTTP cache control. Default: `false`
53-
* [`IMGPROXY_LAST_MODIFIED_BUSTER`]: a global `Last-Modified` buster timestamp. If incoming `If-Modified-Since` is older than this value, imgproxy ignores it and forces revalidation; if origin `Last-Modified` is older, imgproxy replaces it with this timestamp. Use it to invalidate stale client/CDN `Last-Modified` validators after global processing changes. Default: `0`
53+
* [`IMGPROXY_LAST_MODIFIED_BUSTER`]: a global `Last-Modified` buster timestamp in [RFC3339](https://www.rfc-editor.org/rfc/rfc3339.html) format. By setting it to a specific datetime, you can make imgproxy treat all the images as if they were modified at least at that datetime. Default: blank
5454
* [`IMGPROXY_CUSTOM_REQUEST_HEADERS`]: ((pro)) list of custom headers that imgproxy will send while requesting the source image, divided by `\;` (can be redefined by `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`). Example: `X-MyHeader1=Lorem\;X-MyHeader2=Ipsum`
5555
* [`IMGPROXY_CUSTOM_RESPONSE_HEADERS`]: ((pro)) a list of custom response headers, separated by `\;` (can be redefined by `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`). Example: `X-MyHeader1=Lorem\;X-MyHeader2=Ipsum`
5656
* [`IMGPROXY_CUSTOM_HEADERS_SEPARATOR`]: ((pro)) a string that will be used as a custom header separator. Default: `\;`
@@ -167,8 +167,6 @@ When using imgproxy in a development environment, it can be useful to ignore SSL
167167

168168
Also you may want imgproxy to respond with the same error message that it writes to the log:
169169

170-
* [`IMGPROXY_DEVELOPMENT_ERRORS_MODE`]: when `true`, imgproxy will respond with detailed error messages. Not recommended for production because some errors may contain stack traces.
171-
172170
* [`IMGPROXY_ALLOW_SECURITY_OPTIONS`]: when `true`, allows usage of security-related processing options such as `max_src_resolution`, `max_src_file_size`, `max_animation_frames`, `max_animation_frame_resolution`, and `max_result_dimension`. Default: `false`.
173171

174172
:::warning
@@ -423,24 +421,24 @@ imgproxy can detect objects on the image and use them to perform smart cropping,
423421

424422
Read the [Object Detection guide](../features/object_detection.mdx) for more info.
425423

426-
## Object classification
424+
## Classification
427425

428-
imgproxy can classify detected objects on the image and provide detailed information about what the objects are.
426+
imgproxy can classify images by assigning them to predefined categories based on their overall content, similar to object detection but without identifying or locating individual objects.
429427

430-
* [`IMGPROXY_OBJECT_CLASSIFY_NET`]: ((pro)) a path to the classification neural network model in ONNX format. Default: blank
431-
* [`IMGPROXY_OBJECT_CLASSIFY_CLASSES`]: ((pro)) the path to the text file with the class names, one per line. Default: blank
432-
* [`IMGPROXY_OBJECT_CLASSIFY_NET_SIZE`]: ((pro)) the size of the neural network input. The width and the heights of the inputs should be the same, so this config value should be a single number. Default: 224
433-
* [`IMGPROXY_OBJECT_CLASSIFY_THRESHOLD`]: ((pro)) classifications with confidence below this value will be discarded. Default: 0.5
434-
* [`IMGPROXY_OBJECT_CLASSIFY_NORMALIZATION`]: ((pro)) the normalization type to apply to the input image. Possible values are:
428+
* [`IMGPROXY_CLASSIFICATION_NET`]: ((pro)) a path to the classification neural network model in ONNX format. Default: blank
429+
* [`IMGPROXY_CLASSIFICATION_CLASSES`]: ((pro)) the path to the text file with the class names, one per line. Default: blank
430+
* [`IMGPROXY_CLASSIFICATION_NET_SIZE`]: ((pro)) the size of the neural network input. The width and the heights of the inputs should be the same, so this config value should be a single number. Default: 224
431+
* [`IMGPROXY_CLASSIFICATION_THRESHOLD`]: ((pro)) classifications with confidence below this value will be discarded. Default: 0.5
432+
* [`IMGPROXY_CLASSIFICATION_NORMALIZATION`]: ((pro)) the normalization type to apply to the input image. Possible values are:
435433
* `none`: _(default)_ no normalization
436-
* `half`: normalize to [-0.5, 0.5] range
434+
* `half`: normalize to [0, 1] range
437435
* `full`: normalize to [-1, 1] range
438436
* `imagenet`: normalize using ImageNet mean and standard deviation
439-
* [`IMGPROXY_OBJECT_CLASSIFY_LAYOUT`]: ((pro)) the data layout of the neural network input. Possible values are:
440-
* `nchw`: _(default)_ channels first
441-
* `nhwc`: channels last
437+
* [`IMGPROXY_CLASSIFICATION_LAYOUT`]: ((pro)) the data layout of the neural network input. Possible values are:
438+
* `nchw`: channels first (PyTorch default)
439+
* `nhwc`: _(default)_ channels last (TensorFlow default)
442440

443-
Read the [Object Classification guide](../features/object_classification.mdx) for more info.
441+
Read the [Classification guide](../features/classification.mdx) for more info.
444442

445443
## Cache
446444

@@ -453,9 +451,11 @@ imgproxy can cache processed images in various storage backends to improve perfo
453451
* [`IMGPROXY_CACHE_KEY_COOKIES`]: ((pro)) a comma-separated list of HTTP request cookies to include in the cache key. This allows caching different versions of the same image based on cookies. Default: blank
454452
* [`IMGPROXY_CACHE_REPORT_ERRORS`]: ((pro)) when `true`, imgproxy will report cache errors instead of silently falling back to processing without cache. Default: `false`
455453

454+
Read the [Internal cache guide](../cache/internal.mdx) for more info.
455+
456456
### Local filesystem {#cache-storage-local-filesystem}
457457

458-
imgproxy can store cached images on the local filesystem. To use [filesystem cache](../cache/internal/local_filesystem.mdx), set `IMGPROXY_CACHE_USE` to `filesystem`:
458+
imgproxy can store cached images on the local filesystem. To use [filesystem cache](../cache/internal/local_filesystem.mdx), set `IMGPROXY_CACHE_USE` to `fs`:
459459

460460
* [`IMGPROXY_CACHE_LOCAL_FILESYSTEM_ROOT`]: ((pro)) the root directory for filesystem cache. Default: blank
461461

@@ -508,8 +508,6 @@ imgproxy can store cached images in OpenStack Object Storage (Swift). To use [Sw
508508
* [`IMGPROXY_CACHE_SWIFT_TIMEOUT_SECONDS`]: ((pro)) the data channel timeout in seconds for cache operations. Default: 60
509509
* [`IMGPROXY_CACHE_SWIFT_CONNECT_TIMEOUT_SECONDS`]: ((pro)) the connect channel timeout in seconds for cache operations. Default: 10
510510

511-
Read the [Internal cache guide](../cache/internal.mdx) for more info.
512-
513511
## Fallback image
514512

515513
You can set up a fallback image that will be used in case imgproxy is unable to fetch the requested one. Use one of the following variables:

docs/features/cache.mdx

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)