Skip to content

fix(storage): preserve modification time for transformed images - #5204

Merged
dbarrosop merged 1 commit into
mainfrom
5183
Oct 20, 2026
Merged

dbarrosop merged 1 commit into
mainfrom
5183

Conversation

@dbarrosop

Copy link
Copy Markdown
Member

Fixes #5183

Goal

Prevent server errors when browsers and CDNs revalidate transformed storage images using If-Modified-Since or If-Unmodified-Since. Date conditionals should use the source file's modification time, consistent with the advertised Last-Modified header, for both regular and presigned downloads.

Type: Bug fix

Changes

  • Conditional downloads — Use the source metadata's updated_at, formatted as RFC1123, when evaluating date preconditions. Image transformation no longer substitutes the current time in RFC3339, avoiding the parsing failure and allowing unchanged images to return 304 or satisfied preconditions to return 200.
  • Regression coverage — Add 84 HTTP-level cases across regular and presigned download routes, original images and all five transformation parameters (w, h, q, b, f), and dates before, equal to, and after the source timestamp. Fixtures include subsecond metadata to verify HTTP-date precision; assertions cover status, validators, and response-body presence.

Key files

  • services/storage/controller/get_file.go (+2/-5) — Shared download processing and conditional timestamp selection.
  • services/storage/controller/get_file_conditionals_test.go (+213/-0) — HTTP regression matrix using mocked storage boundaries and real image transformation.

Evaluate date conditionals against the source updated_at, matching Last-Modified. This avoids the RFC3339/RFC1123 parsing mismatch and restores cache revalidation for transformed downloads.

Add 84 HTTP regression cases covering image transforms, date boundaries, and regular and presigned downloads.

Checks: controller tests with -race, repository-wide golines and golangci-lint (0 issues). Broader image tests have an unrelated HEIC checksum mismatch in unchanged code.

Fixes #5183
@dbarrosop
dbarrosop added this pull request to stack #5206 October 19, 2026 15:08
@dbarrosop dbarrosop self-assigned this Oct 19, 2026
@dbarrosop
dbarrosop merged commit 9a8709c into main Oct 20, 2026
9 checks passed
@dbarrosop
dbarrosop deleted the 5183 branch October 20, 2026 06:57
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.

storage: 500 when if-modified-since is sent with image transform params

2 participants