fix(media): set Cache-Control by image visibility#2955
Open
cqnykamp wants to merge 1 commit into
Open
Conversation
Public images now respond with `public, max-age=3600` so shared caches (CDN, proxies) can hold them; unlisted and private keep `private, max-age=300` so visibility downgrades propagate within minutes. Closes Doenet#2939
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handleServeImagenow setsCache-Controlbased on the row'svisibilityinstead of alwaysprivate, max-age=300.public→public, max-age=3600(lets CDNs / shared caches hold them)unlisted/private→private, max-age=300(unchanged for private; per the issue, unlisted shouldn't be cached by shared intermediaries even though anyone with the link can fetch)findViewableImagenow returnsvisibilityalongside the existing serving metadata.Picked 3600s for public as suggested in the issue body. Kept 300s for the rest so a visibility downgrade (public → private/delete) propagates within ~5 minutes.
Closes #2939
Test plan
tsc --noEmitand ESLint clean on the four touched filesserve.test.tscases assertingCache-Control: private, max-age=300for owner-fetched private images still pass; new assertions coverpublic, max-age=3600(anonymous public fetch) andprivate, max-age=300(anonymous unlisted fetch)imageContent.test.tsupdated to covervisibilityin the returned shape for private/unlisted/public🤖 Generated with Claude Code