Skip to content

Loading…

20% off your first order with code APEX20 00:00:00 See deals

Technical Notes · Image Optimisation · AVIF & WebP

AVIF/WebP Fallback Notes

Working notes on serving next-gen image formats (AVIF, WebP) with correct fallback to JPEG/PNG for older browsers — markup patterns and server considerations on Hoststack hosting.

See Hosting Plans

Why Fallback Matters, Not Just Format Choice

AVIF and WebP offer meaningfully smaller file sizes than JPEG/PNG at similar quality — but not every browser or tool in your pipeline supports them yet.

🗜️

Smaller File Sizes

AVIF and WebP typically produce 25-50% smaller files than equivalent-quality JPEG, directly improving page load time and Core Web Vitals scores.

🖼️

The Element

The standard, robust way to offer modern formats with fallback — list AVIF, then WebP, then JPEG/PNG as the final fallback, browser picks the first it supports.

🧩

CMS Plugin Support

WordPress and most modern CMS platforms have plugins that auto-generate AVIF/WebP versions and serve them with proper fallback markup automatically.

⚙️

Server-Side Content Negotiation

An alternative to : Accept header-based negotiation at the web server level, serving the best format the browser's Accept header advertises.

🐧

Root Access for Server Config

Content-negotiation approaches (rather than plugin-based markup) require editing Nginx/Apache config — needs root access on a VPS.

💽

Storage for Multiple Formats

Keeping AVIF, WebP, and a JPEG/PNG fallback for every image roughly triples image storage needs — NVMe SSD keeps this cheap and fast regardless.

Two Implementation Approaches

The most portable, widely-compatible approach is the HTML element with multiple tags, each specifying a format via type="image/avif" or type="image/webp", followed by a plain tag as the universal fallback. Browsers evaluate sources top to bottom and use the first one whose format they support, falling back to the src if none match. This works regardless of server configuration and is what most WordPress image-optimisation plugins generate automatically.

The alternative is server-side content negotiation: the browser sends an Accept header indicating which image formats it supports, and the web server (via Nginx map directives or Apache rewrite rules) serves the matching file for the same URL. This keeps your markup simpler (just a normal ) but requires web server configuration — meaning root access on a VPS — and is more fragile to configure correctly, particularly around caching (a CDN or browser cache keyed only on URL, not Accept header, can serve the wrong format to the wrong browser).

Recommendation for most sites

For typical WordPress or CMS-driven sites on shared hosting, use a reputable image optimisation plugin that generates markup — reliable, cache-safe, and doesn't require server config access. Reserve server-side content negotiation for VPS-hosted custom applications where you already control the full request/response pipeline.

Practical Setup on Hoststack Hosting

On shared or cloud hosting (from ₹99/mo) running WordPress, install an image optimisation plugin that supports AVIF/WebP generation with automatic fallback markup — this requires no server-level configuration and works within the platform's existing panel-managed environment.

On a Linux VPS (from ₹399/mo) running a custom application, you have the option to implement server-side content negotiation directly in Nginx if you want cleaner markup, using root access to configure the necessary Accept header handling and cache key adjustments (Vary: Accept) to avoid serving mismatched formats from cache.

Either way, keep an eye on total image storage — NVMe SSD storage on all Hoststack plans keeps the extra format variants cheap to store and fast to serve regardless of which approach you choose.

FAQ

AVIF/WebP fallback questions

No — the element approach works on any hosting, including shared hosting, via a WordPress plugin or manual markup. A VPS is only needed if you want server-side content negotiation instead.
Not if you use the element correctly with a JPEG/PNG fallback — older browsers simply ignore the tags they don't understand and use the fallback image.
AVIF generally compresses better but has slightly less universal browser support and slower encoding time; WebP is very broadly supported today. Listing AVIF first, then WebP, then a JPEG/PNG fallback in a element covers all cases.
It increases storage usage per image (multiple format variants), which NVMe SSD storage handles easily — it doesn't meaningfully affect server response time since the browser only requests the one format it needs.
Only if you're using server-side content negotiation without setting a proper Vary: Accept header on cached responses. The element approach avoids this risk entirely since the format choice happens in the browser, not the cache.

Get NVMe storage for fast, format-flexible image hosting

Shared hosting from ₹99/mo, or Linux VPS from ₹399/mo for custom content-negotiation setups.

See Hosting Plans

Deploy today

Online in 60 seconds. Supported around the clock.

Hosting, VPS and game servers across Mumbai, Delhi, Singapore & Germany — INR billing, GST invoices, and code APEX20 for 20% off your first order.

5,000+ customers served
99.9% uptime SLA
<8ms ping across India
24/7 expert support
WhatsApp Discord