Astro caching with output = server

I added
Astro.response.headers.set("Cache-Control", "public, s-maxage=60, stale-while-revalidate=30");
Astro.response.headers.set("Cache-Control", "public, s-maxage=60, stale-while-revalidate=30");
to one of my pages deployed with @astrojs/cloudflare and I do see the response header in my network tab, but it's seemingly not caching anything. I am displaying the current time and it changes every time I refresh the page. Shouldn't it cache the HTML for 60 seconds? Output is set to server and the page is just this
---
const currentTime = new Date().toLocaleTimeString();

Astro.response.headers.set('Cache-Control', 'public, s-maxage=60, stale-while-revalidate=30');
---

<html>
<head>
<title>Current Time</title>
</head>
<body>
<h1>The current time is: {currentTime}</h1>
</body>
</html>
---
const currentTime = new Date().toLocaleTimeString();

Astro.response.headers.set('Cache-Control', 'public, s-maxage=60, stale-while-revalidate=30');
---

<html>
<head>
<title>Current Time</title>
</head>
<body>
<h1>The current time is: {currentTime}</h1>
</body>
</html>
2 Replies
Amos
AmosOP3w ago
I even have the Cache Rule "Cache Everything" enabled and it's not doing anything
Want results from more Discord servers?
Add your server