---
title: How Framer integrated AVIF for faster, smaller, and sharper images
description: "In May 2024, we shipped AVIF support. All images on Framer are now served as AVIF, which makes them ~20% smaller. However, integrating this format was challenging, partly because converting images to AVIF is slow. Here’s how we solved this."
published: "Nov 6, 2026, 11:03 AM UTC"
---

[Blog](../)

[Engineering](../engineering)

# How Framer does AVIF

[Ivan Akulov](https://twitter.com/iamakulov)

[Jacob Groß](https://twitter.com/kurtextrem)

[Piotr Krawiec](https://twitter.com/heypiotr)

Published 2024/05/30

0 min read

In May 2024, we shipped AVIF support. All images on Framer are now served as AVIF, which makes them \~20% smaller. However, integrating this format was challenging, partly because converting images to AVIF is slow. Here’s how we solved this.

### Challenge: AVIF Encoding Is Slow

At Framer, we [optimize every image](../../help/articles/how-are-images-optimized-in-framer/) on the first request. The optimized image is then cached on a CDN.

This is a common approach, and it works well, but it comes with a drawback. Because the first uncached request has to convert and resize the image, it takes longer than subsequent ones. With [WebP](../../dictionary/webp), “longer” is noticeable but acceptable: in our infrastructure, WebP conversion typically adds 100-300 milliseconds. However, with AVIF, this grows to 1-2 seconds.

*Sidenote: “1-2 seconds? Isn’t that still fast?” — It’s fast, but only outside computer contexts. *[*Research shows*](https://web.dev/articles/rail)* that users start feeling things aren’t instant after just 100 milliseconds.*

Framer’s [cache](../../dictionary/cache) hit for images is \~98%. If we ignored this issue and switched to AVIF, every 50th image would take several seconds to load. We felt this was unacceptable, so Framer’s [Jacob](https://github.com/kurtextrem) came up with, and [Piotr](https://github.com/heypiotr) shipped a clever strategy that avoided that – the `stale-while-revalidate` header.

### Solution: `Stale-While-Revalidate`

`[stale-while-revalidate](https://web.dev/articles/stale-while-revalidate)` is a caching setting. It’s a parameter in the `Cache-Control` header, and it tells CDNs how long they can keep serving the image after it expires:

```
Cache-Control: max-age=3600, stale-while-revalidate=60
               ↑ how long a file can be cached for
                             ↑ how long a CDN can keep serving
                               the file after max-age expires
```

Here’s how we used it to make sure AVIF never makes image responses slow:

#### 1. First Request: WebP
- On the first request, we serve the image as WebP, not as AVIF.
- We also set the `Cache-Control` header to `max-age=0, stale-while-revalidate=31536000`

#### 2. Immediate Expiry
- Because `max-age` is set to 0, the WebP image expires immediately. This prompts the CDN to forward the second request to us.

#### 3. Second Request: AVIF
- When the second request arrives, we serve the image as AVIF.
   - Responding to the second request can take several seconds because AVIF conversion is slow. But thanks to `stale-while-revalidate`, our CDN (CloudFront) keeps serving the WebP image until the conversion is complete.
   - We recognize the second request from the first by the `If-None-Match` header. Only the second request has it.
- When the AVIF image is ready, we return it with `Cache-Control: max-age=31536000`. This allows the CDN to cache and serve it for a long time.

This works surprisingly well – and, best of all, allows us to keep our infrastructure simple. If not for this trick, we’d need to implement a separate queueing system for converting images in the background. But with this trick, we don’t need to – so there’s no extra complexity and no extra bugs.

### When We Don’t Use AVIF

AVIF is now the default format for most images. But there are still a few scenarios where we continue to use WebP:
- **Lossless Images**: AVIF’s lossless compression [is not truly lossless](https://github.com/AOMediaCodec/av1-avif/issues/111) and also [worse than WebP’s](https://siipo.la/blog/whats-the-best-lossless-image-format-comparing-png-webp-avif-and-jpeg-xl). So, for lossless images, we keep using WebP.
- **Animated Images**: The library we rely on for image optimization [doesn’t support animated AVIF images](https://github.com/lovell/sharp/issues/2870), so we continue using WebP for these.

###### Engineering

[Browse all](../engineering)

[Engineering 2026/11/03 Lighthouse 13.6: how we made PageSpeed Insights more accurate for Framer sites Ivan , Jurre 0m](../lighthouse-13-6/)

[Engineering 2026/11/02 Harness 2: executing agent code as it streams Adam 0m](../harness-2/)

[Engineering 2026/07/21 Making the Framer Agent cheaper & faster Adam 0m](../making-the-framer-agent-cheaper-faster/)

[Engineering 2026/07/21 Selecting the unselectable, how we rebuilt block selection in Framer’s rich-text editor Carles 0m](../selecting-the-unselectable/)

## Your next idea starts here

Create personal portfolio, Build startup site, `Launch landing page`, Start company blog

[Start without AI](https://framer.com/signup)

---

## Navigation

- [Enterprise](../../enterprise/)
- [Pricing](../../pricing)
- [Log in](https://framer.com/login)
- [Sign up](https://www.framer.com/r/signup/)
- [Brand guidelines](../../brand)
- [AI](../../ai/)
- [Agents](../../agents/)
- [MCP New](../../mcp/)
- [Design](../../design/)
- [Collaborate](../../collaborate/)
- [CMS](../../cms/)
- [Hosting](../../hosting/)
- [Performance](../../performance/)
- [Analytics](../../analytics)
- [SEO](../../seo/)
- [Skills New](../../skills)
- [Convert](../../convert/)
- [Publish](../../publish/)
- [Updates](../../updates)
- [Templates](https://www.framer.com/community/marketplace/templates/)
- [Components](https://www.framer.com/community/marketplace/components/)
- [Vectors](https://www.framer.com/community/marketplace/vectors/)
- [Plugins](https://www.framer.com/community/marketplace/plugins/)
- [Gallery](https://www.framer.com/community/gallery/)
- [Hire Experts](https://www.framer.com/community/members/)
- [Switch New](../../switch/)
- [Agencies](../../agencies/)
- [Startups](../../startups/)
- [Academy](../../academy/)
- [Desktop App](../../downloads/)
- [Developers](../../developers/)
- [Affiliates](../../creators)
- [Experts New](../../expert/apply/)
- [Guides](../../guides)
- [Blog](../)
- [Newsletter](../../newsletter)
- [Stories](../../stories/)
- [Skills Index New](../../skills/index)
- [Students](../../education/students/)
- [Ambassadors](../../)
- [Help Articles](../../help/)
- [Meetups](../../meetups/)
- [Contact](../../contact/)
- [Designers](../../solutions/designers/)
- [Agencies](../../solutions/agencies/)
- [Marketers](../../solutions/marketers/)
- [Growth](../../solutions/growth/)
- [Builders](../../solutions/builders/)
- [Engineers](../../solutions/engineers/)
- [Site Teams](../../solutions/site-teams/)
- [Founders](../../solutions/founders/)
- [AI website builder](../../solutions/ai-website-builder/)
- [AI design agent](../../solutions/ai-designer/)
- [Pro sites](../../solutions/website-builder/)
- [Landing pages](../../solutions/landing-pages/)
- [Portfolio maker](../../solutions/portfolio-website/)
- [UI/UX design](../../solutions/ui-ux-design/)
- [Figma to HTML](../../solutions/figma-to-html/)
- [No-code](../../solutions/no-code-website-builder/)
- [Compare](../../compare)
- [Webflow](../../compare/framer-vs-webflow)
- [Figma](../../compare/framer-vs-figma)
- [Wix](../../compare/framer-vs-wix)
- [Squarespace](../../compare/framer-vs-squarespace)
- [WordPress](../../compare/framer-vs-wordpress)
- [Readymag](../../compare/framer-vs-readymag)
- [Ceros](../../compare/framer-vs-ceros)
- [Unbounce](../../compare/framer-vs-unbounce)
- [Lovable](../../compare/framer-vs-lovable)
- [Claude Code](../../compare/framer-vs-claude-code)
- [ChatGPT](../../compare/framer-vs-chatgpt)
- [Codex](../../compare/framer-vs-codex)
- [Contentful](../../compare/framer-vs-contentful)
- [Sanity](../../compare/framer-vs-sanity)
- [AEM](../../compare/framer-vs-adobe-experience-manager)
- [Replit](../../compare/framer-vs-replit)
- [Astro](../../compare/framer-vs-astro)
- [v0](../../compare/framer-vs-v0)
- [About New](../../about)
- [Careers](../../careers/)
- [Security](../../legal/security)
- [Brand](../../brand)
- [Abuse](mailto:abuse@framer.com)
- [Legal](../../legal/community-terms)
- [Trust](https://app.eu.vanta.com/framer.com/trust/ow67ujg7iav0t6qtd1o6r2)
- [Merch](../../store)
- [Keyboard](../../f1)
- [Stack Score](../../stack-score/)
- [Free domains](../../domains/)
- [CanvasBench](../../canvasbench/)
- [State of Sites](https://www.framer.com/state-of-sites-2026/)
- [AEO scanner](../../aeo)
- [Link Preview](https://www.linkpreview.app/)
- [Checking status](https://www.framerstatus.com/)
