Repository navigation
Store cache and inline playback headers on MP4 outputs - #11
Open
bluebird42 wants to merge 1 commit into
Open
bluebird42 wants to merge 1 commit into
bluebird42 wants to merge 1 commit into
Conversation
Public MP4 and fMP4 objects are served straight from object storage or a CDN, so the caching policy has to live on the object itself. Versioned output keys get a one-year immutable lifetime; unversioned legacy keys can be rewritten in place and get 24 hours. Private signed media URLs override the stored policy so a shared cache never outlives the signature. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Depending on your CDN provider and configuration, caching may already be handled through fallback rules. Explicit cache headers can still provide useful defaults for both CDN and browser caching. I'll take a closer look at the proposed cache durations. Thanks! |
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
Public MP4 and fMP4 outputs (progressive renditions, HLS
init.mp4and.m4ssegments) are served directly from object storage or the per-space CDN. Until now they were written without aCache-Controlheader, so browsers and the CDN had to fall back to heuristic caching.MaveCore.Media.Storagenow adds two headers when it writes a public object with content typevideo/mp4oraudio/mp4:Cache-ControlContent-Disposition{embed}/v{n}/…)public, max-age=31536000, immutableinline{embed}/…)public, max-age=86400inlineVersioned keys are never rewritten with different bytes, so they can be cached for a year without revalidation. Unversioned legacy keys can be replaced in place. A short lifetime keeps a stale or mixed byte-range cache from outliving a replacement.
The headers are applied in every public write path:
put/6andput_file/6(and their*_publicwrappers)presigned_put_url/6for booster-published HLS files. These headers are signed, and the booster already sends the returned headers unchanged.Private writes (
public: false) and non-MP4 objects such as manifests, playlists and captions are unchanged.Private playback
Private media redirects to a signed storage URL. Those URLs now pass
response-cache-control=private, max-age=<ttl>, which replaces the stored public policy for that response. This way a shared cache can't keep a signed response longer than the signature, and the response never getspubliccaching.Notes
Accept-Rangesand CORS are unchanged: storage handles range requests itself, and CORS is already configured through bucket rules.+faststart.Testing
mix test(1197 passed)mix credo --strictmix precommitaudio/mp4segments, private writes, multipart initiation and signed PUT headers. The playback controller test checks the privateresponse-cache-controloverride.