refactor: modularize chat backend, update docs for .m4s segments
This commit is contained in:
1 parent
46e878bef6
commit
b3a10ba3ef
24 files changed
+3771
-2781
No files matched your search
@@ -1,25 +1,25 @@
|
||||
# Cloudflare Cache Rules for Linear Void (per ADR-001)
|
||||
|
||||
## Recommended Cache Rules for media.example.com
|
||||
## Recommended Cache Rules for media.linearvoid.tv
|
||||
|
||||
1. **.ts segments (immutable)**
|
||||
- Expression: (http.host eq "media.example.com" and http.request.uri.path contains ".ts")
|
||||
1. **.m4s and .ts segments (immutable)**
|
||||
- Expression: (http.host eq "media.linearvoid.tv" and (http.request.uri.path contains ".ts" or http.request.uri.path contains ".m4s"))
|
||||
- Cache status: Eligible for cache
|
||||
- Edge Cache TTL: 1 month (or `Cache-Control: public, max-age=31536000, immutable` from origin)
|
||||
- Cache Everything: Yes
|
||||
|
||||
2. **.m3u8 manifests (live)**
|
||||
- Expression: (http.host eq "media.example.com" and http.request.uri.path contains ".m3u8")
|
||||
- Expression: (http.host eq "media.linearvoid.tv" and http.request.uri.path contains ".m3u8")
|
||||
- Cache status: Eligible for cache
|
||||
- Edge Cache TTL: 10 seconds
|
||||
- Cache-Control: public, max-age=10, must-revalidate
|
||||
- Edge Cache TTL: 2 seconds
|
||||
- Cache-Control: public, max-age=2, must-revalidate
|
||||
|
||||
3. **Static assets**
|
||||
- Expression: (http.host eq "example.com" and http.request.uri.path contains ".js" or http.request.uri.path contains ".css")
|
||||
- Expression: (http.host eq "linearvoid.tv" and http.request.uri.path contains ".js" or http.request.uri.path contains ".css")
|
||||
- Edge Cache TTL: 1 year (with hash in filename for immutable caching)
|
||||
|
||||
**Tiered Cache**: Enable Smart Tiered Cache for R2 custom domain to reduce origin requests.
|
||||
|
||||
**WAF**: Enable basic rate limiting and bot management for /ws and admin routes.
|
||||
|
||||
These rules ensure high cache hit ratio for .ts segments while keeping live manifests fresh. Monitor cache hit ratio in Cloudflare analytics.
|
||||
These rules ensure high cache hit ratio for .m4s and .ts segments while keeping live manifests fresh. Monitor cache hit ratio in Cloudflare analytics.
|
||||
@@ -6,8 +6,8 @@ addEventListener("fetch", (event) => {
|
||||
async function handleRequest(request) {
|
||||
const url = new URL(request.url);
|
||||
|
||||
// Add immutable cache headers for .ts segments
|
||||
if (url.pathname.endsWith(".ts")) {
|
||||
// Add immutable cache headers for .m4s segments
|
||||
if (url.pathname.endsWith(".m4s")) {
|
||||
const response = await fetch(request);
|
||||
const headers = new Headers(response.headers);
|
||||
headers.set("Cache-Control", "public, max-age=31536000, immutable");
|
||||
|
||||
Reference in new issue
Block a user