You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,20 @@ If you want API reference content to regenerate automatically before every local
105
105
106
106
Do not commit these hooks, as CI does not have `dotnet-apiref` installed and the build will fail. The generated API reference files are already committed to the repository.
107
107
108
+
## Caching
109
+
110
+
The site is served through a Cloudflare Worker ([`workers/docs-redirects`](workers/docs-redirects)) which handles redirects, trailing-slash normalization, and edge caching.
Copy file name to clipboardExpand all lines: redirects/cloudflare_worker_kv_redirects/README.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,9 +43,12 @@ This produces `kv-redirects.json` (gitignored).
43
43
44
44
```bash
45
45
npx wrangler kv bulk put kv-redirects.json \
46
-
--namespace-id ae8131374b0d409e9ab0537882dafe0b
46
+
--namespace-id ae8131374b0d409e9ab0537882dafe0b \
47
+
--remote
47
48
```
48
49
50
+
> **Note:** Wrangler v4 defaults to local KV. The `--remote` flag is required to write to the production KV namespace.
51
+
49
52
## CI/CD
50
53
51
54
KV entries are automatically regenerated and uploaded on every deploy to `main` via the `docs.avaloniaui.net CI/CD` GitHub Actions workflow (`.github/workflows/docs-avaloniaui-net.yml`). A validation step checks that all redirect targets point to allowed domains (`docs.avaloniaui.net`, `github.com/AvaloniaUI`) before uploading.
Copy file name to clipboardExpand all lines: workers/docs-redirects/README.md
+16-4Lines changed: 16 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,15 +6,16 @@ Cloudflare Worker that handles server-side redirects and trailing-slash normaliz
6
6
7
7
1.**KV redirects** — Looks up the request path in the `DOCS_REDIRECTS` KV namespace. If a match is found, returns a `301` redirect to the target URL.
8
8
2.**Trailing-slash rewrite** — If no redirect is found and the path looks like a page (no file extension), the Worker internally rewrites the request to append a trailing slash. S3-compatible object storage (e.g. AWS, Scaleway) always returns a `302` redirect to the trailing-slash version when a path is requested without one (e.g. `/docs/welcome` → `302` → `/docs/welcome/`). This rewrite eliminates that round-trip by fetching the trailing-slash path internally, so the browser gets the page directly.
9
-
3.**Static asset bypass** — Requests for static assets (`.js`, `.css`, `.png`, etc. and `/assets/*` paths) skip KV lookup entirely and pass straight through to origin.
9
+
3.**Edge caching** — HTML pages are cached at the Cloudflare edge for 7 days (`cacheTtl: 604800`, `cacheEverything: true`). Browsers receive `Cache-Control: public, max-age=300` (5 minutes). The edge cache is purged by hostname on every deploy via the CI/CD workflow, so new content is served immediately after a push to `main`.
10
+
4.**Static asset bypass** — Requests for static assets (`.js`, `.css`, `.png`, etc. and `/assets/*` paths) skip KV lookup and edge caching, passing straight through to origin (Cloudflare caches these by default based on file extension).
10
11
11
12
## Request flow
12
13
13
14
```
14
15
Browser request
15
16
│
16
17
▼
17
-
Static asset? ──YES──▶ passthrough to origin
18
+
Static asset? ──YES──▶ passthrough to origin (cached by file extension)
The edge cache for `docs.avaloniaui.net` is purged by hostname on every deploy to `main` via the CI/CD workflow, so new content is available immediately regardless of edge TTL.
0 commit comments