Serving files
Give each file version its own cacheable address, sign CDN access to private streams, and purge every cached copy when a file is deleted.
- Required 1
- Recommended 2
Required
Purge cached copies when a file is deleted or removed
MED-21When a file is deleted, erased or taken down, purge its addresses and every derived file from the CDN in the same job. Close the request only after the purge is confirmed.
Recommended
Give every file version its own address
MED-19Put a version or a content hash in the address of every public file and derived file. A changed file gets a new address, so each address can be cached as long as a hashed asset.
Sign CDN access to private media for the whole stream
MED-20Serve private video and other media made of many files through the CDN with a signed cookie or token for one path prefix. The CDN checks it on every segment, and the app checks access before it issues one.
Rules on serving files in other playbooks
- Serve private files through short-lived links signs single downloads and sets
Content-Disposition. - Let large downloads resume with range requests answers 206 for big files.
- Cache files for a year and pages briefly sets the cache lifetimes.
- Stop browsers guessing file types sends
nosniffand the right type. - Keep private pages out of shared caches and Keep unkeyed headers from changing cached pages are the cache attack tests.
- Use a managed DNS and CDN that exports your zone names the delivery network.
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/files-and-media/serving-files">Agent Wranglers files and media playbook</a>. In code you write, add a comment next to it with the same link.