SEV Rewrite-Free WebP for W3TC
SEV Rewrite-Free WebP for W3TC — это легкий плагин-компаньон для W3 Total Cache, который автоматически обслуживает изображения WebP для браузеров, поддерживающих их.
Unlike traditional WebP delivery methods, this plugin does not rely on Apache or Nginx rewrite rules. No changes to .htaccess, mod_rewrite, or web server configuration are required. Instead, it rewrites image URLs directly in the generated HTML before the page is sent to the visitor.
This makes the plugin particularly useful on managed hosting environments, including many Plesk installations, where configuring or relying on web server rewrite rules is difficult, restricted, or simply not practical. If W3 Total Cache ImageService has already generated a WebP version of an image, this plugin serves it without requiring any server-side rewrite configuration.
Это независимое, неофициальное дополнение, не связанное, не одобренное и не спонсируемое BoldGrid / W3 EDGE, создателями W3 Total Cache. «W3 Total Cache» является торговой маркой соответствующего владельца и используется здесь только для описания совместимости.
Features
- No Apache or Nginx rewrite rules required.
- No
.htaccessmodifications. - Automatically detects WebP support via the browser’s
Acceptheader. - Rewrites image URLs only when a corresponding WebP image exists.
- Supports
src,srcset,data-src, anddata-srcsetattributes. - Sends a
Vary: Acceptheader for correct browser, CDN, and proxy caching. - Extends the W3 Total Cache page cache key so WebP and non-WebP pages are cached separately.
- Lightweight and requires no configuration.
Принцип работы:
- A visitor requests a page.
- The plugin checks the HTTP
Acceptheader to determine whether the browser supports WebP. - It scans the post content for image URLs (
src,srcset,data-src, anddata-srcset). - For each image, it checks whether W3 Total Cache ImageService has already generated a WebP version.
- If a WebP image exists, the corresponding URL in the generated HTML is replaced with the
.webpURL. - Отправляется заголовок ответа
Vary: Accept, чтобы CDN и обратные прокси-серверы кэшировали версии WebP и не-WebP отдельно. - The W3 Total Cache page cache key is extended with
:webpor:no-webp, ensuring W3 Total Cache stores separate cached pages for browsers with and without WebP support.
Требования:
- W3 Total Cache должен быть установлен и активен.
- Images must have been converted using Media → W3TC Image Service.
Limitations
This plugin does not convert images to WebP. Image conversion is handled entirely by W3 Total Cache ImageService. If no WebP version exists for an image, the original image URL remains unchanged.