Skip to content

fix(media): set Cache-Control by image visibility#2955

Open
cqnykamp wants to merge 1 commit into
Doenet:mainfrom
cqnykamp:feat/issue-2939
Open

fix(media): set Cache-Control by image visibility#2955
cqnykamp wants to merge 1 commit into
Doenet:mainfrom
cqnykamp:feat/issue-2939

Conversation

@cqnykamp

Copy link
Copy Markdown
Contributor

Summary

  • handleServeImage now sets Cache-Control based on the row's visibility instead of always private, max-age=300.
    • publicpublic, max-age=3600 (lets CDNs / shared caches hold them)
    • unlisted / privateprivate, 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)
  • findViewableImage now returns visibility alongside 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 --noEmit and ESLint clean on the four touched files
  • Existing serve.test.ts cases asserting Cache-Control: private, max-age=300 for owner-fetched private images still pass; new assertions cover public, max-age=3600 (anonymous public fetch) and private, max-age=300 (anonymous unlisted fetch)
  • imageContent.test.ts updated to cover visibility in the returned shape for private/unlisted/public
  • Couldn't run vitest locally — the sandbox cannot reach the docker mysql on localhost:3309 — CI will exercise it

🤖 Generated with Claude Code

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
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.

Image serve: public images sent with Cache-Control: private

1 participant