CDN Image Optimization Guide: WebP, AVIF, Resizing, and Cache Variants
image optimizationWebPAVIFCDN cachingresponsive imagesCore Web Vitals

CDN Image Optimization Guide: WebP, AVIF, Resizing, and Cache Variants

CCache Cloud Editorial Team
2026-11-19
7 min read

A practical CDN image optimization checklist covering WebP, AVIF, responsive resizing, cache variants, headers, quality, and measurement.

CDN image optimization is a balance between smaller transfers, acceptable visual quality, predictable cache behavior, and manageable origin load. This reusable checklist explains how to choose WebP or AVIF, resize images for real display dimensions, control responsive cache variants, configure long-lived caching, and verify that optimization improves performance without creating operational problems.

Overview

Images often account for a substantial share of a page’s transferred bytes, but sending every image through the most aggressive optimization setting is not a complete strategy. A CDN image workflow must answer four questions:

  1. Which format is appropriate? The best choice depends on image content, required quality, browser support in your audience, and the capabilities of your CDN or image service.
  2. Which dimensions are needed? A 2,400-pixel source is wasteful when the image is displayed at 600 pixels, but an undersized source can look soft on high-density screens.
  3. How many cache variants should exist? Variants for width, format, quality, crop, and device can multiply quickly and reduce cache efficiency.
  4. How will changes be delivered? Long-lived caching works best when image URLs are versioned or fingerprinted so that a new file does not depend on an uncertain purge process.

WebP is a practical general-purpose format for many photographic and graphic images. AVIF can provide further compression in suitable workflows, but encoding time, transformation support, visual behavior, and fallback handling should be tested rather than assumed. JPEG and PNG still have valid roles: JPEG may remain useful for compatibility or an existing media pipeline, while PNG is appropriate when lossless detail or transparency is important. The goal is not to select one universal format; it is to create a repeatable decision and measurement process.

For broader performance work, pair this guide with a repeatable CDN performance testing workflow. Image savings should be evaluated alongside LCP, TTFB, cache hit ratio, and the page’s overall request pattern.

Checklist by scenario

Scenario 1: New editorial or marketing images

  • Record the image’s intended use: hero, card, thumbnail, product gallery, logo, diagram, or decorative background.
  • Identify the largest display width that the design actually uses. Do not generate arbitrary widths simply because the original file is large.
  • Keep an original source outside the delivery path when future crops, edits, or higher-resolution versions may be needed.
  • Generate a limited width set, such as small, medium, large, and maximum display widths. The exact values should match your layout rather than a generic preset.
  • Use a modern format where the CDN and clients support it, with a tested fallback for requests that cannot use that format.
  • Set descriptive alternative text for meaningful images. Compression does not replace accessibility metadata.

Scenario 2: Responsive images on content pages

  • Use srcset and sizes when the browser must choose among several widths.
  • Make sizes reflect the layout. If a card occupies half the viewport on desktop but nearly the full width on mobile, describe those conditions accurately.
  • Choose widths around actual breakpoints and common display sizes. Too many near-duplicate widths create extra cache keys without meaningful savings.
  • Keep the transformation parameters stable. A URL that changes unnecessarily for each request can prevent reusable edge caching.
  • Use the image’s intrinsic dimensions or an aspect-ratio rule to reduce layout shifts while the file loads.

Scenario 3: WebP versus AVIF

Use caseStarting approachWhat to test
PhotographsCompare WebP and AVIF at equivalent visual qualityFile size, fine detail, gradients, encoding time, and fallback behavior
Illustrations and UI graphicsTest WebP, AVIF, and lossless options where edges matterText sharpness, transparency, flat-color artifacts, and dimensions
Logos and iconsPrefer the format that preserves edges and transparency reliablySmall-size appearance, transparent backgrounds, and browser handling
Legacy media libraryOptimize incrementally rather than transforming every asset at onceTemplate compatibility, URL stability, and purge or rollback procedures

Do not compare formats using only a nominal quality number. Quality settings are not standardized between encoders, and an image that is smaller may still be unsuitable if it introduces ringing, banding, blur, or color shifts. Select a representative sample: a photograph with texture, a dark image, a bright gradient, a transparent graphic, and a product image with fine edges.

Scenario 4: Product catalogs and WooCommerce

  • Separate product thumbnails, listing cards, gallery images, zoom images, and social-sharing images. Each has a different display requirement.
  • Do not apply a single aggressive quality rule to every product image if packaging text, fabric texture, or fine product detail is important.
  • Exclude account, cart, checkout, and other personalized responses from image transformation rules that depend on user-specific content.
  • Confirm that transformed URLs remain stable when products are updated, and document how old variants are purged or allowed to expire.

Scenario 5: CDN transformation and origin fallback

  • Define an explicit fallback when a transformation fails: serve the original, a previously generated variant, or a controlled error response.
  • Prevent repeated transformation failures from sending every request back to the origin.
  • Cache successful transformed responses at the edge and monitor origin requests separately from cache hits.
  • Consider origin shielding or tiered caching if a popular image causes avoidable bursts against the source server; review the origin shielding and tiered caching guide for the trade-offs.

What to double-check

Cache keys and headers

Inspect which request attributes affect the cache key. Width, format, quality, crop, and sometimes device-related headers may be relevant. Avoid varying on broad or unstable headers unless the CDN handles them deliberately. If format negotiation uses the Accept header, verify that the response includes an appropriate Vary behavior or that the CDN has a documented alternative. Otherwise, one client could receive a representation intended for another.

For immutable, fingerprinted image URLs, a long-lived Cache-Control policy is usually easier to operate than short expiry periods. If URLs are not versioned, use a shorter lifetime or a reliable purge process. Test both a cache miss and a cache hit, and confirm that the response includes the expected content type, content length, cache status, and caching headers.

Quality and dimensions

Open representative outputs at their real display size. A file can pass a byte-size target while looking poor on a large screen, or remain unnecessarily large because the source dimension exceeds the rendered box. Compare the largest common viewport, a high-density display, and a constrained mobile layout.

Performance evidence

Measure before and after with a controlled test. Record transferred image bytes, the number of image requests, the LCP resource when applicable, cache status, and origin response time. Repeat from more than one region when audience geography matters. A smaller file does not automatically improve the experience if it is delayed by a cache miss, transformation queue, slow DNS route, or a blocked request.

Use the website cache audit checklist to investigate missed hits, and review regional routing with the DNS and CDN routing guide when first-byte performance varies by location.

Common mistakes

  • Creating a variant for every possible width: This increases storage and cache fragmentation. Start with widths supported by the actual layout and expand only when measurement justifies it.
  • Using device categories as a substitute for dimensions: “Mobile” and “desktop” are too broad to describe every display. Width-based responsive selection is usually more precise.
  • Changing quality without visual review: Encoder quality values are not interchangeable. Review difficult images, not just an easy sample.
  • Optimizing the original in place: Replacing source files can make future crops and reversions difficult. Preserve a source copy and deliver derived variants.
  • Ignoring cache invalidation: A changed image at the same URL may remain stale at browsers or edge locations. Use versioned URLs or test your purge path before a launch.
  • Transforming personalized or protected media indiscriminately: Check access controls, signed URLs, and cache scope before allowing an edge to store the result.
  • Lazy-loading the key visual: Lazy loading below-the-fold images can help, but the primary above-the-fold image should be evaluated carefully so optimization does not delay discovery.
  • Judging success by Lighthouse alone: Lab tools are useful, but CDN cache status, real-user data, and origin metrics reveal operational issues that a single test may miss.

When to revisit

Revisit this checklist before seasonal campaigns, major media-library cleanups, redesigns, CMS migrations, and recurring Core Web Vitals reviews. It should also be reviewed when your CDN adds or changes image-transformation features, when supported formats or browser behavior change materially, or when a new template introduces different image dimensions.

For each review, keep a small audit record:

  • Five to ten representative source images and their use cases.
  • Displayed width, generated widths, format, quality setting, and resulting file size.
  • Cache-control policy, cache-key inputs, and purge or versioning method.
  • Cache hit ratio and origin request behavior for popular assets.
  • Before-and-after transfer size and performance measurements from the same test conditions.
  • Known exceptions, such as transparent graphics, high-detail product images, or protected media.

Finish by testing one complete user journey, not just an individual image: load a listing page, open a detail page, switch gallery images, and repeat after a cache purge or URL version change. Then check both the edge response and the origin logs. If the results are acceptable, document the chosen variants and make them part of the publishing workflow. If they are not, change one variable at a time—format, width, quality, or caching rule—so the next measurement shows what actually improved.

Related Topics

#image optimization#WebP#AVIF#CDN caching#responsive images#Core Web Vitals
C

Cache Cloud Editorial Team

Technical SEO Editors

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.