Skip to content

fix(assets): allow 304 Not Modified status to bypass redirect check while revalidating cached assets#15935

Open
oliverlynch wants to merge 3 commits intowithastro:mainfrom
oliverlynch:main
Open

fix(assets): allow 304 Not Modified status to bypass redirect check while revalidating cached assets#15935
oliverlynch wants to merge 3 commits intowithastro:mainfrom
oliverlynch:main

Conversation

@oliverlynch
Copy link
Contributor

Changes

Fix bug #15920 introduced in 35bc814 by skipping the redirect check for Not Modified status 304

A few other small improvements

  • replace double awaits with Promise.all
  • explicitly return null data from revalidateRemoteImage when there is no change - before this relied on the response body for unchanged assets being empty, and it was confusing.
  • explicitly write cache file in utf-8, as we are reading it in utf-8
  • reword a few comments

Testing

I ran pnpm run test:match "assets" with 0 errors, however the full pnpm run test fails on my machine.

I don't believe there is any test coverage of the revalidation feature as it depends on remote servers, however I quickly tested the fix by loading a remote image and editing the cache file and it seems to work as expected.

Docs

No user facing changes - no docs changes required.

- replace double awaits with Promise.all
- explicitly return null data from revalidateRemoteImage when there is
no change
- explicitly write cache file in utf-8, as we are reading it in utf-8
@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 16, 2026
@changeset-bot
Copy link

changeset-bot bot commented Mar 16, 2026

🦋 Changeset detected

Latest commit: 27ff03d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 16, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing oliverlynch:main (27ff03d) with main (23d5244)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant