feat: let the content app return 304 Not Modified for unchanged files - #7995
feat: let the content app return 304 Not Modified for unchanged files#7995carlosthe19916 wants to merge 1 commit into
Conversation
2246d02 to
95c8958
Compare
2e9b68b to
a193f54
Compare
a193f54 to
46bc167
Compare
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
d1101e2 to
6a6872c
Compare
|
I really don't like what the AI wrote. Here's how I would have done it: 5164e37 The AI is somehow doing too much and too little at the same time. Lots of refactoring and not even implementing full functionality for the cloud backends. And man, AI really does love adding tests... After I spent so much effort to reduce the test suite time too. Can you implement something similar to what I wrote? I haven't fully tested it and the utility method isn't all there, but it's a better approach, imo. Also, can you do some tests with the queries I wrote for finding the |
Summary
If-Modified-Sincewith 304 Not Modified and no body, so an edge cache can keep its copy instead of downloading the file again.Last-Modifiedis when that unit joined the served repository version (RepositoryContent.pulp_created). Disk mtime moves on copy/restore, and the version’s created time would make every cached file look stale on each publish.ArtifactResponse). Object-storage 302s get neitherLast-ModifiednorCache-Control: public, because a signed URL must not be stored or reused as if it were the file.Fixes #7929.
Guards still run first. A matching
If-Modified-Sinceis 304; otherwise the response is 200 withLast-Modifiedand the body. If there is no membership row (publish-generated metadata, remote-only distribution), Pulp omitsLast-Modifiedand never returns 304.Artifact 200s and 304s include
Cache-Control: public, max-age=0, must-revalidateso the edge revalidates on every use. Plugins can still override headers withcontent_headers_for. This change does not addETag._serve_cais the single place that looks up the timestamp and may 304 (published files, pass-through, repository versions, plugincontent_handler(), grace-period fallback, pull-through). Grace-period fallback uses the old publication’s version so the timestamp is not the current one. On-demand streams 304 before opening the remote. A stream that has already started writing is never turned into a 304.aiohttp’s
FileResponsewould overwriteLast-Modifiedwith disk mtime.PulpFileResponsestops that, does not send a disk-timeETag, and does not clearIf-Range.When Redis is on, the handler returns a cacheable 200 and the cache layer owns the 304: it stores
last_modified, 304s a hit without rebuilding the response, and never writes a 304 into Redis.Not in this PR: 304 on S3/Azure/GCS redirects,
ETag/If-None-Match, or a fallback timestamp for metadata with no membership row.Test plan
PulpFileResponsedoes not 304 on file mtime and does not clearIf-Rangelast_modified, 304s a hit without rebuilding, and never caches a 304