← Back to Internal system builders
See how it helps
2.
Private media delivery
Delivers private media efficiently without letting shared caches or reusable links bypass the application’s access decisions.
cdn-private-media-delivery
Team members using this skill
When is it useful?
Use it when protected images, videos or downloads pass through a CDN or are shared using expiring links.
What does it help you do?
- Separates public assets, private media and revocable shares.
- Prevents caching authorization redirects across different users.
- Coordinates signed access, expiration and range requests.
Try asking this
Design private video delivery without leaking one customer’s download redirect. Request the same video as two customers, then revoke one share. Cached responses must not bypass the revoked permission or reveal the other customer's link.
Detailed documentation
Read the skill’s original instructions, examples and checks in their authored language.
Show less
CDN & Private Media Delivery
Delivering media and files fast without leaking private tenant data requires aligning storage keys, Cache-Control headers, CDN signing and application share-link tokens with the file's exact access model.
1. Classify Assets by Access Model First
Never put private user uploads in a public bucket "just to make CDN caching easier":
- Truly Public Assets (marketing images, public product catalog photos, public avatars where policy explicitly states they are world-readable):
- Serve via CDN with immutable content-addressed or versioned keys (
avatars/{id}.{hash}.webp) andCache-Control: public, max-age=31536000, immutable.
- Serve via CDN with immutable content-addressed or versioned keys (
- Authenticated Tenant / User Files (project attachments, private media, invoices, exports):
- Bucket remains 100% private.
- Authorize every access request in application code first, then deliver via one of two patterns:
- Short-lived CDN / Object-Store Signed URL (CloudFront Signed URL, Cloudflare R2/Workers signed token, S3 Presigned GET, GCS/Azure SAS) with a short TTL (
60–900seconds). - Signed Cookies scoped to a path prefix (e.g., CloudFront Signed Cookies scoped to
tenants/{tenant_id}/videos/{video_id}/*): essential for HLS/DASH video streaming, where a video player requests hundreds of.m3u8and.ts/.m4ssegment URLs and signing every segment URL individually in the manifest is brittle.
- Short-lived CDN / Object-Store Signed URL (CloudFront Signed URL, Cloudflare R2/Workers signed token, S3 Presigned GET, GCS/Azure SAS) with a short TTL (
- Revocable External Share Links (
/s/{share_token}):- Do not hand out a 7-day S3 presigned URL directly as a user-facing "Share Link" if the product allows revoking share links, password-protecting links or tracking download counts!
- Instead, issue an application share URL (
/s/{high_entropy_token}) backed by afile_sharestable (id,file_id,token_hash,expires_at,revoked_at,max_downloads,download_count,password_hash). - When a visitor hits
/s/{token}, validate that the share is not revoked/expired and the parent file is not deleted, then redirect (302withCache-Control: private, no-store) to a 60-second signed storage URL.
2. Cache-Control & Vary Discipline
- Authorization-check endpoints (
/api/files/{id}/download,/s/{token}): must always returnCache-Control: private, no-storeso shared proxies or CDNs never cache User A's redirect for User B. - Signed immutable derivative objects: once authorized via a signed CDN URL, the underlying immutable derivative (
thumb_256_v1.webp) can be cached at the CDN edge (s-maxage) while requiring a valid signature on every edge request. - Range & CORS headers on CDN: forward
Range/Originheaders when serving video/audio or canvas/WebGL textures across origins, and includeVary: Origin, Rangeso partial byte responses are cached properly. - Never log signed URLs or share tokens in plaintext access logs or analytics beacons (
Refererheader leakage — setReferrer-Policy: no-referreron download/share pages).
Included files 1
SKILL.md
