Image Optimization
This section uses an On/Off switch in the top corner instead of the Create/Delete/Save buttons and a separate Enable checkbox. Off = delete the domain's entire image optimization configuration (all rules + URL params settings).
Image Optimization lets the edge decode, resize and convert images right at the edge (usually to WebP/AVIF, which are smaller than JPEG/PNG) before returning them to the client. There are 2 independent paths:
- Rules (automatic): the admin sets rules that match by file extension/path/hostname and enforce the format + quality + size limits. The client does not need to do anything.
- URL params (requested by the client): the client adds a query (
?w=300&h=200&f=webp&q=80&blur=2&rot=90…). Enabled only when Allow URL params = true.
Use this when: you have many images and want to reduce bandwidth/speed up loading without a separate build pipeline. Example: a shop has 10,000 JPEG images — enable the "Default WebP" rule so visitors whose browsers support WebP automatically get the lighter version.
Before you start
- The domain has been added and points to VNIS.
- Turn on the On switch of the Image Optimization section (in the top corner) — this is the master gate: when it is Off (not configured), rules, URL params and
?format=do not run.
How to configure
This section uses an On/Off switch in the top corner: On = create and apply the configuration (saved immediately, no separate Save needed); Off = delete the entire image optimization configuration. The fields and rules are shown even when Off — set them first, then switch On.
- Go to Domains → select the domain → Image Optimization tab.

- Review/edit the list of Rules — by default there is 1 "Default WebP" rule. Each rule sets Output format, Quality, Max width/height, Match extensions, Match path/type, Priority, and has its own Enabled toggle per rule (independent of the section's On/Off switch).
- (Optional) Turn on Allow URL transform parameters to let clients transform images through the query; then set the clamp ceilings (max width/height/quality/blur/sharpen, size step, allowed formats, disabled ops).
- Turn on the On switch in the top corner of the section — the configuration is created and enabled immediately. For later changes, click Save (shown only when On and there are unsaved changes).
Configuration fields
Domain level:
| Field | Meaning | Values | Default | Notes |
|---|---|---|---|---|
| On/Off switch (corner of the section) | Master gate that enables all image optimization — On = creates the configuration, Off = deletes it | Switch | Off (not configured) | Off = rules, URL params and ?format= are all skipped, and the configuration is deleted (to turn it back on, you have to configure it again); you cannot switch On while a rule has errors (empty name/regex/size) |
| Allow URL params | Lets clients transform images through the query | On/off | Off | Has effect only when Enable is on |
| Max width (px) | Clamp ceiling for ?w= | ≤ 8192 | 2000 | Can be set up to 8192, but the edge clamps the effective value to 8000 |
| Max height (px) | Clamp ceiling for ?h= | ≤ 8192 | 2000 | Can be set up to 8192, but the edge clamps the effective value to 8000 |
| Max quality | Clamp ceiling for ?q= | 1–100 | 90 | The client's ?q= is clamped and then rounded to a multiple of 5 |
| Allowed formats | Formats the client can choose on the resize path | Subset of {webp,avif,jpeg,png,original}, ≤8 | ["webp","jpeg","png"] | original is always allowed; removing avif affects only the resize path |
| Max blur / Max sharpen | Clamp ceiling for ?blur= / ?sharpen= | 0.0–50.0 | 10.0 | — |
| Dimension step (px) | Quantizes dimensions to limit the number of cache variants | ≥2 (when URL params are on), ≤1024 | 10 | 0/1 are blocked when Allow URL params is on |
| Disabled operations | Operations the client cannot use | Subset of {blur,sharpen,rotate,grayscale,flip,mirror,avif,smart}, ≤16 | Empty | avif here only blocks ?f=avif on the resize path, not ?format=avif |
| Rules | Automatic rule set | ≤50 rules | 1 "Default WebP" rule | See the table below |
Each rule:
| Field | Meaning | Values | Default | Notes |
|---|---|---|---|---|
| Rule name | Label | ≤128 characters, not empty | — | Empty → 400 |
| Enabled | Turns the rule on/off | On/off | On | — |
| Priority | Match order | 0–10000 | 100 (new rule) / 1000 (Default WebP) | Lower number = matched first |
| Match hostnames | Restricts by subdomain | List | Empty = all hostnames | — |
| Output format | Output format | {webp,avif,jpeg,png,original} | webp | Webp/avif require the client to send Accept: image/webp/image/avif; otherwise the rule is skipped |
| Quality | Compression quality | ≤100 | 80 | 0 = use the system default (80) |
| Max width / Max height | Size limit (downscale only) | ≤16384 | 0 (no limit) | — |
| Match extensions | Matching file extensions | Subset of {jpg,jpeg,png,webp,gif,tiff,tif,bmp} | Empty = all images | Case-insensitive match |
| Match path / type | Path pattern + how it is interpreted | Type ∈ {prefix,exact,suffix,contains,wildcard,regex} | prefix | Regex ≤500 characters and must compile |
?format= / ?f= is an always-on override. When Image Optimization is enabled, the client can always choose the output format with ?format=webp|avif|jpeg|png — without needing Allow URL params and without being limited by Allowed formats or the avif entry in Disabled operations. This is intentional (by design).
Configuration examples
Example 1 — Automatically convert JPEG/PNG to WebP (default rule).
- Switch: On · keep the "Default WebP" rule (output
webp, quality 80, matches jpg/jpeg/png/gif/bmp/tiff). - Expected result: clients that send
Accept: image/webpreceive WebP images; clients that do not support WebP receive the original image. - How to check:
curl -H "Accept: image/webp" -D - https://domain/img/a.jpg -o /dev/null→content-type: image/webp; without the Accept header → the original JPEG is returned.
Example 2 — Let clients resize through the URL, with safe clamping.
- Allow URL params: on · Max width
1000· Size step10· Max quality85. - Result:
?w=99999is clamped to ≤1000 and snapped to a multiple of 10;?q=200is clamped to 85 and then rounded to a multiple of 5. Invalid values (e.g.?w=abc) are ignored and do not cause an error (the clamp-not-reject principle). - How to check: load
https://domain/img/a.jpg?w=99999→ the image is ≤1000px wide.
Example 3 — Use AVIF on request but block AVIF on the resize path.
- Allow URL params: on · Disabled operations: add
avif. - Result:
?f=avif(resize path) falls back to Original, but?format=avif(always-on override) still returns AVIF (for clients that sendAccept: image/avif). - How to check:
?f=avif→ no AVIF;?format=avifwithAccept: image/avif→content-type: image/avif.
The edge has hard protective limits: under heavy load the original image may be returned; a source image > 64M pixels (8000×8000) or an original file > 15 MiB or an animated image (GIF/APNG/animated WebP) → the original image is returned; output is at most 8000 px per side; AVIF after resize > 2M pixels → the original image is returned.
Order of evaluation
- When several rules match: the lower priority number wins (sorted ascending). The UI has up/down buttons to change the order.
- The On/Off switch = whether the configuration exists and is the master gate: Off = configuration deleted → nothing runs; the domain returns to the default (no optimization). When On but Allow URL params is off, only rules +
?format=work;?w=/h=/blur=are ignored. (The per-rule Enabled toggle is independent of the section switch.) - A rule with webp/avif output requires the client to send the matching
Accept; otherwise that rule is skipped and evaluation falls through to the next lower-priority rule. - Each transform variant has its own cache key (a suffix is appended), so variants do not overwrite each other.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Save returns 400 "name is required" | The rule has no name | Give the rule a name |
| Save returns 400 "invalid regex pattern" | Match type is regex but the pattern is invalid | Fix the regex (the UI also blocks Save/switching On) |
| The On switch cannot be turned on (greyed out) | A rule has errors (empty name / invalid regex / size over the limit) | Fix the rule errors and switch again |
| All rules are gone after switching Off | Off = delete the entire configuration (by design) | Turn it back on and re-enter the rules/settings |
| Save returns 400 about size step | Allow URL params is on but size step < 2 | Set size step to ≥ 2 (≤1024) |
| Save returns 400 about max width/height | Over the limit (8192 for URL params; 16384 for rules) | Lower it to within the limit |
| The WebP rule is on but JPEG is still returned | The client does not send Accept: image/webp | Expected — the rule applies only when the client accepts the format |
?w=200 has no effect | Allow URL params is not on | Turn on Allow URL params |
| Animated images are not converted | VNIS does not transform animated images | Expected — the original image is returned to avoid losing frames |
FAQ
- What is the maximum number of rules? 50 rules per domain.
- Can invalid query values break images? No — the URL params path follows the clamp-not-reject principle: out-of-range values are clamped or ignored, and a request never fails because of image parameters.
- Does disabling
avifin Disabled ops block AVIF completely? Not completely — it only blocks?f=avifon the resize path; the?format=avifoverride still works. - Why is the original image sometimes returned even though optimization is on? This can be due to overload, an image that is too large, an animated image, or a client that does not send a matching
Accept. - What is
originalin Output format/Allowed formats? It keeps the original format and only applies quality/resize;originalis always allowed.