Skip to content

Set ETag to the md5 of the render on cache-miss responses - #73

Draft
jtomson wants to merge 2 commits into
masterfrom
render-etag-md5
Draft

jtomson wants to merge 2 commits into
masterfrom
render-etag-md5

Conversation

@jtomson

@jtomson jtomson commented Oct 30, 2026 •

Copy link
Copy Markdown

What this does

When a render isn't cached yet, imgproxy returns it without an ETag. Once it's in the render bucket, S3 serves it with an ETag that is the hex md5 of the bytes. So frames only get a usable digest on cache hits, and in a sample from a frame's OkHttp cache 10 of 16 images had none.

This sets the ETag on the cache-miss response to the same quoted hex md5 S3 would return, so every image response carries a digest the frame can check its cached copy against. It's set regardless of IMGPROXY_USE_ETAG, which we leave off. imgproxy's own ETag is a sha256 of the options and source, not of the body, so the frame can't check against it.

How I tested it

Added TestSetRenderETagIsQuotedHexMD5 for the header format.
go test . passes.
Checked a live cache hit through imgproxy.pushd.com. It's served by S3 through CloudFront with SSE-S3 (AES256), and the ETag matched the md5 of the 724,337-byte body exactly. CloudFront passes it through unchanged.
The cache-miss ETag is the md5 of the same bytes that go to S3 in a single PutObject, so the two should match. After deploy I'll request an unrendered URL twice and confirm the miss and hit ETags are identical.

🤖 Generated with Claude Code

@jtomson
jtomson marked this pull request as ready for review November 3, 2026 19:59
jtomson and others added 2 commits November 3, 2026 15:01
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
We leave IMGPROXY_USE_ETAG off, so the frame always gets an md5 of the body to check its cached copy against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jtomson
jtomson marked this pull request as draft November 3, 2026 20:14
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.

1 participant