Skip to content

perf(storage-s3): avoid getObject call if ETag matches#15295

Merged
paulpopus merged 12 commits intopayloadcms:mainfrom
andershermansen:storage-s3-perf
Apr 8, 2026
Merged

perf(storage-s3): avoid getObject call if ETag matches#15295
paulpopus merged 12 commits intopayloadcms:mainfrom
andershermansen:storage-s3-perf

Conversation

@andershermansen
Copy link
Copy Markdown
Contributor

What?

Avoid unnecessary getObject call to S3 when the ETag matches.

Why?

Range support introduced an early headObject call, which already returns ETag and metadata; we can use that to short‑circuit with 304 and save a fetch.

How?

By using response headers from headObject and check ETag matching before invoking getObject.

Added a test case for verifying 200 status when If-None-Match does not match, and 304 status with empty body when If-None-Match is included and matching.

@paulpopus paulpopus self-assigned this Apr 8, 2026
@paulpopus paulpopus enabled auto-merge (squash) April 8, 2026 13:58
@paulpopus paulpopus merged commit 7ccc3f0 into payloadcms:main Apr 8, 2026
157 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

🚀 This is included in version v3.82.1

milamer pushed a commit to milamer/payload that referenced this pull request Apr 20, 2026
)

### What?

Avoid unnecessary getObject call to S3 when the ETag matches.

### Why?

Range support introduced an early headObject call, which already returns
ETag and metadata; we can use that to short‑circuit with 304 and save a
fetch.

### How?

By using response headers from headObject and check ETag matching before
invoking getObject.

Added a test case for verifying 200 status when If-None-Match does not
match, and 304 status with empty body when If-None-Match is included and
matching.

---------

Co-authored-by: Paul Popus <paul@payloadcms.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants