Capture upstream Last-Modified/ETag and support conditional revalidation #83
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Verified against
mainat61f42e6. Covers the "Last-Modified headers" item inTODO.md.The scaffolding exists and is entirely unpopulated:
ImageResponse.LastModified(internal/imgcache/imgcache.go:111-112) — declared, never set, never readSourceMetadata.LastModifiedandSourceMetadata.ETag(internal/imgcache/storage.go:211-212) — declared, never populatedSo pixa neither records what the upstream told it about freshness nor uses it. Two consequences:
Last-Modified, so clients and CDNs can only revalidate via the ETag pixa generates itself. That works, but it discards information the origin already gave us.304 Not Modifiedfor free. This becomes directly relevant if theCacheTTLissue is resolved by enforcing the TTL — without conditional revalidation, every expiry means a full re-download of unchanged bytes.Definition of done
Last-ModifiedandETagfrom the upstream response are captured intoSourceMetadataand persisted with the source entry.If-Modified-Since/If-None-Matchwhen the stored values exist, and a304is handled by refreshing the freshness timestamp without re-downloading or re-processing.Last-Modifiedwhere a meaningful value exists. Do not synthesize one from cache write time and present it as origin truth — an absent header is better than a wrong one.internal/handlersalready has ETag/304 tests — they must still pass unmodified.Last-Modifiedresults in a stored value and a response header; a re-fetch sends the conditional header; a304response does not re-download and does not corrupt the cached entry.make checkgreen.Coordination
Pairs naturally with the
CacheTTLissue — that issue decides when to revalidate, this one supplies the mechanism to do it cheaply. If both are done, do this one first.