Inicio - Documentación - POM Cache - 04 Apache and web server - WebP delivery: POM Cache, image generation, and Apache responsibilities

WebP delivery: POM Cache, image generation, and Apache responsibilities

POM Cache does not create WebP images and does not replace image URLs inside cached HTML. A same-folder WebP deployment works because three independent layers agree on one convention.

The three responsibilities

Layer Responsibility
Image pipeline Create a valid WebP alternative and keep it synchronized with the original
Apache or another origin server Serve the alternative only when the browser accepts WebP and the file exists
CDN Cache the original and WebP representations without mixing them

POM Cache’s only connection is indirect: a cached HTML page can contain the original image URL, just like a dynamic WordPress page.

Why the HTML can keep the original URL

Suppose the page contains:

<img src="/wp-content/uploads/2026/07/dish.jpg" alt="Dish">

The browser still requests dish.jpg. Apache can inspect the request’s Accept header:

Accept: image/avif,image/webp,image/*,*/*

If the agreed alternative exists, the server internally maps the request to the WebP file while preserving the public URL. A browser without WebP support receives dish.jpg.

This avoids generating a different HTML page for each image format.

Choose one filename convention

Two common same-folder layouts are:

dish.jpg
dish.jpg.webp

or:

dish.jpg
dish.webp

The first convention retains the complete original filename and is the convention used by the example in this chapter. Do not combine both unless the rule defines a deterministic priority.

The image generator, rewrite condition, cleanup process, and backup policy must all use the same naming contract.

Accept is not Accept-Encoding

Image format negotiation uses:

Vary: Accept

HTML/CSS/JavaScript compression uses:

Vary: Accept-Encoding

They are different request dimensions. Brotli support does not imply WebP support, and a cache key that varies only on Accept-Encoding cannot safely store both JPEG/PNG and WebP bodies under one image URL.

What the server must guarantee

For an original JPEG or PNG request:

  1. confirm the browser explicitly accepts image/webp;
  2. confirm the original exists;
  3. confirm the same-folder alternative exists;
  4. rewrite internally to that exact file;
  5. send Content-Type: image/webp;
  6. merge Accept into Vary;
  7. otherwise serve the original unchanged.

The rule should not call PHP, search unrelated directories, generate images, or return WebP merely because a filename can be guessed.

What the image process must guarantee

Before enabling negotiation, decide:

  • which source formats receive WebP alternatives;
  • whether transparency and animation are preserved;
  • how quality is selected;
  • how regenerated WordPress sizes update their alternatives;
  • what happens when the original is edited, replaced, or deleted;
  • how failed or partial conversions are detected.

Apache verifies existence, not image integrity. A corrupt .webp file still exists and can be served.

What the CDN must guarantee

If one viewer URL can return two bodies, the edge policy must include the relevant Accept distinction or use an equivalent format-negotiation feature. Forwarding Vary: Accept from the origin is useful, but the CDN’s cache policy remains authoritative.

After changing the rule or replacing an alternative, invalidate the public original-image path and every edge variant represented by that path.

Start with Serve a same-folder WebP alternative with Apache, then validate the original-image fallback.