From 331b5e276dcb2bb8200ea7252e41ccee8cf2cce1 Mon Sep 17 00:00:00 2001 From: g0ldyy <153996346+g0ldyy@users.noreply.github.com> Date: Fri, 9 Jan 2026 23:03:28 +0100 Subject: [PATCH 1/4] feat: cloudflare cache guide --- deployment/cloudflare-cache-rules.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 deployment/cloudflare-cache-rules.md diff --git a/deployment/cloudflare-cache-rules.md b/deployment/cloudflare-cache-rules.md new file mode 100644 index 0000000..761fd62 --- /dev/null +++ b/deployment/cloudflare-cache-rules.md @@ -0,0 +1,20 @@ +# Cloudflare Configuration + +To optimize performance, configure Cloudflare to offload traffic from your server. We use **Cache Rules** to cache public stream results while respecting the application's cache headers. + +## 1. Public Streams (Cache Rule) +Allow Cloudflare to cache public stream results. Comet automatically controls the duration (TTL) and freshness (Stale-While-Revalidate) via headers. + +* **Rule Name**: Public Streams +* **Expression**: `(starts_with(http.request.uri.path, "/stream/"))` +* **Action**: Eligible for Cache +* **Edge TTL**: Use cache-control header if present +* **Browser TTL**: Respect origin +* **Serve stale content while revalidating**: On + +## 2. Tiered Cache +Enable **Tiered Cache** in **Caching > Tiered Cache**. +This minimizes requests to your origin by checking other Cloudflare datacenters first. + +--- +*Note: Private streams (URLs containing your configuration) are automatically excluded because they do not start with `/stream/`.* From 1841dceaf332587ebb0767d8a55ab7781f129008 Mon Sep 17 00:00:00 2001 From: g0ldyy <153996346+g0ldyy@users.noreply.github.com> Date: Fri, 9 Jan 2026 23:26:51 +0100 Subject: [PATCH 2/4] feat: improve cloudflare cache rules --- deployment/cloudflare-cache-rules.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/deployment/cloudflare-cache-rules.md b/deployment/cloudflare-cache-rules.md index 761fd62..30f9a22 100644 --- a/deployment/cloudflare-cache-rules.md +++ b/deployment/cloudflare-cache-rules.md @@ -1,9 +1,9 @@ # Cloudflare Configuration -To optimize performance, configure Cloudflare to offload traffic from your server. We use **Cache Rules** to cache public stream results while respecting the application's cache headers. +To optimize performance, configure Cloudflare to offload traffic from your server. We use **Cache Rules** to cache stream results while respecting the application's cache headers. ## 1. Public Streams (Cache Rule) -Allow Cloudflare to cache public stream results. Comet automatically controls the duration (TTL) and freshness (Stale-While-Revalidate) via headers. +Cache public stream results. Comet controls the TTL via headers. * **Rule Name**: Public Streams * **Expression**: `(starts_with(http.request.uri.path, "/stream/"))` @@ -12,9 +12,16 @@ Allow Cloudflare to cache public stream results. Comet automatically controls th * **Browser TTL**: Respect origin * **Serve stale content while revalidating**: On -## 2. Tiered Cache +## 2. Private Streams (Cache Rule) +Cache private stream results (with user config in URL). The config is part of the URL, so each user+media combination has a unique cache key. This prevents the same user from hitting the origin repeatedly for the same content. + +* **Rule Name**: Private Streams +* **Expression**: `(http.request.uri.path contains "/stream/" and not starts_with(http.request.uri.path, "/stream/"))` +* **Action**: Eligible for Cache +* **Edge TTL**: Use cache-control header if present +* **Browser TTL**: Respect origin +* **Serve stale content while revalidating**: On + +## 3. Tiered Cache Enable **Tiered Cache** in **Caching > Tiered Cache**. This minimizes requests to your origin by checking other Cloudflare datacenters first. - ---- -*Note: Private streams (URLs containing your configuration) are automatically excluded because they do not start with `/stream/`.* From 8b8b76324b4f1570512e695918f1266765c712e1 Mon Sep 17 00:00:00 2001 From: g0ldyy <153996346+g0ldyy@users.noreply.github.com> Date: Fri, 9 Jan 2026 23:41:56 +0100 Subject: [PATCH 3/4] feat: improve cloudflare guide --- deployment/cloudflare-cache-rules.md | 40 +++++++++++++++++++--------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/deployment/cloudflare-cache-rules.md b/deployment/cloudflare-cache-rules.md index 30f9a22..49fb1f8 100644 --- a/deployment/cloudflare-cache-rules.md +++ b/deployment/cloudflare-cache-rules.md @@ -1,27 +1,41 @@ # Cloudflare Configuration -To optimize performance, configure Cloudflare to offload traffic from your server. We use **Cache Rules** to cache stream results while respecting the application's cache headers. +To optimize performance, configure Cloudflare to offload traffic from your server. We use **Cache Rules** to cache responses while respecting the application's cache headers. -## 1. Public Streams (Cache Rule) -Cache public stream results. Comet controls the TTL via headers. +## 1. Streams (Cache Rule) +Cache all stream results (public and private). Comet controls the TTL via headers. -* **Rule Name**: Public Streams -* **Expression**: `(starts_with(http.request.uri.path, "/stream/"))` +* **Rule Name**: Streams +* **Expression**: `(http.request.uri.path contains "/stream/")` * **Action**: Eligible for Cache -* **Edge TTL**: Use cache-control header if present +* **Edge TTL**: Use cache-control header if present (first option) * **Browser TTL**: Respect origin * **Serve stale content while revalidating**: On -## 2. Private Streams (Cache Rule) -Cache private stream results (with user config in URL). The config is part of the URL, so each user+media combination has a unique cache key. This prevents the same user from hitting the origin repeatedly for the same content. +## 2. Configure Page (Cache Rule) +Cache the configuration page. -* **Rule Name**: Private Streams -* **Expression**: `(http.request.uri.path contains "/stream/" and not starts_with(http.request.uri.path, "/stream/"))` +* **Rule Name**: Configure Page +* **Expression**: `(http.request.uri.path eq "/configure")` * **Action**: Eligible for Cache -* **Edge TTL**: Use cache-control header if present +* **Edge TTL**: Use cache-control header if present (first option) * **Browser TTL**: Respect origin -* **Serve stale content while revalidating**: On -## 3. Tiered Cache +## 3. Manifest (Cache Rule) +Cache manifest.json responses. + +* **Rule Name**: Manifest +* **Expression**: `(ends_with(http.request.uri.path, "/manifest.json"))` +* **Action**: Eligible for Cache +* **Edge TTL**: Use cache-control header if present (first option) +* **Browser TTL**: Respect origin + +## 4. Tiered Cache Enable **Tiered Cache** in **Caching > Tiered Cache**. This minimizes requests to your origin by checking other Cloudflare datacenters first. + +## 5. Network Optimizations +In **Speed > Protocol**: + +* **HTTP/3 (QUIC)**: On (faster connections, especially on mobile) +* **0-RTT Connection Resumption**: On (reduces latency for repeat visitors) From 3ee32c3badb47e57403021249061fc2e5cf16939 Mon Sep 17 00:00:00 2001 From: g0ldyy <153996346+g0ldyy@users.noreply.github.com> Date: Fri, 9 Jan 2026 23:52:34 +0100 Subject: [PATCH 4/4] feat: remove manifest from cloudflare cache guide --- deployment/cloudflare-cache-rules.md | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/deployment/cloudflare-cache-rules.md b/deployment/cloudflare-cache-rules.md index 49fb1f8..f260f30 100644 --- a/deployment/cloudflare-cache-rules.md +++ b/deployment/cloudflare-cache-rules.md @@ -21,20 +21,11 @@ Cache the configuration page. * **Edge TTL**: Use cache-control header if present (first option) * **Browser TTL**: Respect origin -## 3. Manifest (Cache Rule) -Cache manifest.json responses. - -* **Rule Name**: Manifest -* **Expression**: `(ends_with(http.request.uri.path, "/manifest.json"))` -* **Action**: Eligible for Cache -* **Edge TTL**: Use cache-control header if present (first option) -* **Browser TTL**: Respect origin - -## 4. Tiered Cache +## 3. Tiered Cache Enable **Tiered Cache** in **Caching > Tiered Cache**. This minimizes requests to your origin by checking other Cloudflare datacenters first. -## 5. Network Optimizations +## 4. Network Optimizations In **Speed > Protocol**: * **HTTP/3 (QUIC)**: On (faster connections, especially on mobile)