Keep the original image as a safe fallback
WebP negotiation must be additive. The JPEG or PNG remains the canonical fallback for browsers, bots, feeds, email clients, social crawlers, and any request whose edge policy does not support WebP safely.
Do not delete the original after creating its alternative.
Four outcomes to verify
| Browser request | WebP file | Expected body |
|---|---|---|
Accept includes image/webp |
Exists | WebP |
Accept excludes WebP |
Exists | Original JPEG/PNG |
Accept includes WebP |
Missing | Original JPEG/PNG |
No useful Accept header |
Exists | Original JPEG/PNG |
The public URL remains the original image URL in every row.
Test a missing alternative
Choose an original image for which no .webp sibling exists.
- Request it with
Accept: image/webp. - Confirm status, dimensions, and body remain the original.
- Confirm
Content-Typematches the original extension. - Confirm Apache does not return a 404 for the guessed WebP path.
The existence condition is the fallback mechanism. It should not redirect the browser to a missing filename.
Test an incompatible client
Request a pair that does have a WebP alternative, but omit WebP from Accept.
Expected:
- the original bytes are served;
Content-Typeremainsimage/jpegorimage/png;- the response remains visually correct;
- the edge does not reuse an earlier WebP body.
Test through both origin and CDN. A correct Apache fallback can still be defeated by an edge cache that ignores Accept.
Preserve original-image behavior
Check image features that can be lost during conversion:
- PNG transparency;
- embedded color profiles;
- EXIF orientation;
- animation;
- very small icons where WebP may not be smaller;
- WordPress-generated crops and responsive sizes.
The rewrite cannot determine whether the alternative is semantically equivalent. That is the image pipeline’s responsibility.
Replacement and deletion lifecycle
When WordPress replaces an image:
- regenerate every expected WebP sibling;
- verify the alternative’s modification time and contents;
- remove obsolete alternatives that no longer have an original;
- invalidate the public image path at the CDN;
- verify both compatible and fallback requests again.
If only the original changes while an older .webp remains, compatible browsers can see different content from incompatible clients.
Cache-key acceptance test
Run requests in both orders:
- original-only
Accept, then WebPAccept; - WebP
Accept, then original-onlyAccept.
Repeat after the edge is warm. Correct output must not depend on which format populated the CDN first.
Inspect:
Content-Type;Vary;- edge hit/miss evidence;
- response size;
- decoded image format;
- visible dimensions and transparency.
Roll back without breaking images
To disable the integration:
- remove or disable the negotiation rule through the server deployment process;
- validate and reload Apache;
- invalidate the affected public image paths;
- confirm all clients receive the original files;
- leave WebP siblings in place until rollback is proven.
Because cached HTML continues to reference the original URL, no POM Cache HTML regeneration is normally required solely to stop same-URL WebP negotiation.