Skip to content

Commit cf22139

Browse files
authored
perf: reduce downloads page cache staleness (#376)
The download pages are SSR Worker responses. Workers Cache is not enabled in the current deployment, so the shared-cache directives do not currently provide edge caching for these routes. Astro supports route-level Workers Cache configuration, but does not automatically generate a dedicated cache-enabled Worker entrypoint for SSR routes that would benefit from caching. Enabling Workers Cache on the default entrypoint would also make static asset requests incur standard Workers request charges, even on cache hits. Use a private 60-second browser cache for the download pages instead, while preserving the existing long-lived static asset caching.
1 parent 3e85f3f commit cf22139

4 files changed

Lines changed: 4 additions & 8 deletions

File tree

src/pages/downloads/folia.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import Layout from "@/layouts/Layout.astro";
55
import SoftwareDownloadPage from "@/components/data/SoftwareDownloadPage.svelte";
66
import { fetchDownloadsPageData } from "@/utils/download";
77
8-
Astro.response.headers.set("Cache-Control", "public, max-age=300, s-maxage=600, stale-while-revalidate=120");
9-
Astro.response.headers.set("CDN-Cache-Control", "public, max-age=600, stale-while-revalidate=120");
8+
Astro.response.headers.set("Cache-Control", "private, max-age=60");
109
const data = await fetchDownloadsPageData("folia", env.WEBSITE_CACHE);
1110
---
1211

src/pages/downloads/paper.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import Layout from "@/layouts/Layout.astro";
55
import SoftwareDownloadPage from "@/components/data/SoftwareDownloadPage.svelte";
66
import { fetchDownloadsPageData } from "@/utils/download";
77
8-
Astro.response.headers.set("Cache-Control", "public, max-age=300, s-maxage=600, stale-while-revalidate=120");
9-
Astro.response.headers.set("CDN-Cache-Control", "public, max-age=600, stale-while-revalidate=120");
8+
Astro.response.headers.set("Cache-Control", "private, max-age=60");
109
const data = await fetchDownloadsPageData("paper", env.WEBSITE_CACHE);
1110
---
1211

src/pages/downloads/velocity.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import Layout from "@/layouts/Layout.astro";
55
import SoftwareDownloadPage from "@/components/data/SoftwareDownloadPage.svelte";
66
import { fetchDownloadsPageData } from "@/utils/download";
77
8-
Astro.response.headers.set("Cache-Control", "public, max-age=300, s-maxage=600, stale-while-revalidate=120");
9-
Astro.response.headers.set("CDN-Cache-Control", "public, max-age=600, stale-while-revalidate=120");
8+
Astro.response.headers.set("Cache-Control", "private, max-age=60");
109
const data = await fetchDownloadsPageData("velocity", env.WEBSITE_CACHE);
1110
---
1211

src/pages/downloads/waterfall.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import Layout from "@/layouts/Layout.astro";
55
import SoftwareDownloadPage from "@/components/data/SoftwareDownloadPage.svelte";
66
import { fetchDownloadsPageData } from "@/utils/download";
77
8-
Astro.response.headers.set("Cache-Control", "public, max-age=300, s-maxage=600, stale-while-revalidate=120");
9-
Astro.response.headers.set("CDN-Cache-Control", "public, max-age=600, stale-while-revalidate=120");
8+
Astro.response.headers.set("Cache-Control", "private, max-age=60");
109
const data = await fetchDownloadsPageData("waterfall", env.WEBSITE_CACHE);
1110
1211
const descriptionHtml = `

0 commit comments

Comments
 (0)