Skip to content

Loading…

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 <picture> Element

The standard, robust way to offer modern formats with fallback — list AVIF, then WebP, then JPEG/PNG as the final <img> 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 <picture>: 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 <picture> element with multiple <source> tags, each specifying a format via type="image/avif" or type="image/webp", followed by a plain <img> tag as the universal fallback. Browsers evaluate sources top to bottom and use the first one whose format they support, falling back to the <img> 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 <img src="photo.jpg">) 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 <picture> 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 <picture> 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 <picture> 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 <picture> element correctly with a JPEG/PNG <img> fallback — older browsers simply ignore the <source> 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 <picture> 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 <picture> element approach avoids this risk entirely since the format choice happens in the browser, not the cache.
You can pay in Indian rupees by UPI, RuPay, Visa, Mastercard or net banking.
Yes. A GST-compliant invoice is created for every order and can be downloaded any time from the Client Area.
Open a ticket from the Client Area for tracked support, or message us on WhatsApp or Discord for quick questions. Every channel is listed on our contact page.
You can request cancellation from the Client Area at any time. Whether a refund applies depends on the product and how long it has been active — the full terms are in our Refund Policy.
Yes. Open a ticket from the Client Area or message us, and we will move you to a larger plan as your needs grow.

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, France & the USA — INR billing, GST invoices, and code APEX20 for 20% off your first order.

5,000+ customers served
99.9% uptime SLA
<8ms ping within Mumbai
24/7 expert support