Skip to content

Images binding: allow setting headers on .response()#6869

Open
Monark-Arkmon wants to merge 2 commits into
cloudflare:mainfrom
Monark-Arkmon:monark/images-response-headers
Open

Images binding: allow setting headers on .response()#6869
Monark-Arkmon wants to merge 2 commits into
cloudflare:mainfrom
Monark-Arkmon:monark/images-response-headers

Conversation

@Monark-Arkmon

Copy link
Copy Markdown

response() now accepts an optional headers option, so you can set Cache-Control (or anything else) without manually rebuilding the Response:

result.response({
  headers: { 'Cache-Control': 'public, max-age=3600, stale-while-revalidate=86400' },
});

content-type is always taken from the transformed image and can't be overridden by a header you pass in.

This pairs nicely with Workers Cache - now that Cache-Control on the response is all you need to get a transform cached at the edge, it was a bit annoying to have to hand-roll headers just to set that one thing.

@Monark-Arkmon Monark-Arkmon requested review from a team as code owners July 7, 2026 15:50
@Monark-Arkmon Monark-Arkmon force-pushed the monark/images-response-headers branch from 832525e to 0eb7d7c Compare July 7, 2026 16:21
@ns476

ns476 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

LGTM ✅

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants