WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Image generation: Etag header is ignored #14942

@volpeon

Description

@volpeon

Astro Info

Astro                    v5.16.3
Vite                     v6.4.1
Node                     v25.2.0
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx (v4.3.12)
                         astro-compressor (v1.2.0)
                         @astrojs/sitemap (v3.6.0)

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I use Strapi to manage media files for my website. I recently added an Etag header, expecting that Astro would honor it as per #12426. However, it never re-uses images from its cache and keeps processing them on every build.

I found out that the problem is likely an internal caching mechanism in fetch here:

const req = new Request(src, { headers });
const res = await fetch(req);

I assume it checks the Etag header internally and simply replays the original 200 response from the cache. Astro won't detect this as a cached response since it checks if the body is empty, which isn't the case here.

if (revalidatedData.data.length) {

Adding cache: "no-cache" to the Request options got it working, so that might be one possible solution.

What's the expected result?

Image processing should be skipped for images sent with an Etag header if its value hasn't changed. This should be indicated with the (revalidated cache entry) info when building.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-vddoqki9-dwswdbrh

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)feat: assetsRelated to the Assets feature (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions