Skip to main content

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.

  1. Go to Domains → select the domain → Image Optimization tab. Go to Domains → select the domain → Image Optimization tab
  2. 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).
  3. (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).
  4. 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:

FieldMeaningValuesDefaultNotes
On/Off switch (corner of the section)Master gate that enables all image optimization — On = creates the configuration, Off = deletes itSwitchOff (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 paramsLets clients transform images through the queryOn/offOffHas effect only when Enable is on
Max width (px)Clamp ceiling for ?w=≤ 81922000Can be set up to 8192, but the edge clamps the effective value to 8000
Max height (px)Clamp ceiling for ?h=≤ 81922000Can be set up to 8192, but the edge clamps the effective value to 8000
Max qualityClamp ceiling for ?q=1–10090The client's ?q= is clamped and then rounded to a multiple of 5
Allowed formatsFormats the client can choose on the resize pathSubset of {webp,avif,jpeg,png,original}, ≤8["webp","jpeg","png"]original is always allowed; removing avif affects only the resize path
Max blur / Max sharpenClamp ceiling for ?blur= / ?sharpen=0.0–50.010.0—
Dimension step (px)Quantizes dimensions to limit the number of cache variants≥2 (when URL params are on), ≤1024100/1 are blocked when Allow URL params is on
Disabled operationsOperations the client cannot useSubset of {blur,sharpen,rotate,grayscale,flip,mirror,avif,smart}, ≤16Emptyavif here only blocks ?f=avif on the resize path, not ?format=avif
RulesAutomatic rule set≤50 rules1 "Default WebP" ruleSee the table below

Each rule:

FieldMeaningValuesDefaultNotes
Rule nameLabel≤128 characters, not empty—Empty → 400
EnabledTurns the rule on/offOn/offOn—
PriorityMatch order0–10000100 (new rule) / 1000 (Default WebP)Lower number = matched first
Match hostnamesRestricts by subdomainListEmpty = all hostnames—
Output formatOutput format{webp,avif,jpeg,png,original}webpWebp/avif require the client to send Accept: image/webp/image/avif; otherwise the rule is skipped
QualityCompression quality≤100800 = use the system default (80)
Max width / Max heightSize limit (downscale only)≤163840 (no limit)—
Match extensionsMatching file extensionsSubset of {jpg,jpeg,png,webp,gif,tiff,tif,bmp}Empty = all imagesCase-insensitive match
Match path / typePath pattern + how it is interpretedType ∈ {prefix,exact,suffix,contains,wildcard,regex}prefixRegex ≤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/webp receive 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 step 10 · Max quality 85.
  • Result: ?w=99999 is clamped to ≤1000 and snapped to a multiple of 10; ?q=200 is 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 send Accept: image/avif).
  • How to check: ?f=avif → no AVIF; ?format=avif with Accept: 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​

SymptomCauseFix
Save returns 400 "name is required"The rule has no nameGive the rule a name
Save returns 400 "invalid regex pattern"Match type is regex but the pattern is invalidFix 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 OffOff = delete the entire configuration (by design)Turn it back on and re-enter the rules/settings
Save returns 400 about size stepAllow URL params is on but size step < 2Set size step to ≥ 2 (≤1024)
Save returns 400 about max width/heightOver the limit (8192 for URL params; 16384 for rules)Lower it to within the limit
The WebP rule is on but JPEG is still returnedThe client does not send Accept: image/webpExpected — the rule applies only when the client accepts the format
?w=200 has no effectAllow URL params is not onTurn on Allow URL params
Animated images are not convertedVNIS does not transform animated imagesExpected — 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 avif in Disabled ops block AVIF completely? Not completely — it only blocks ?f=avif on the resize path; the ?format=avif override 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 original in Output format/Allowed formats? It keeps the original format and only applies quality/resize; original is always allowed.