Why does the Cache API cache automatically add or change the `maxage` in the `cache-control` header?

I wrote the following code

const cache = cache.default;
const cacheKey = generateCacheKey(request);
const cacheData = await cache.match(cacheKey);

if (cacheData != null) {
  return cacheData;
}

const beresp = await fetch("https://example.com", { headers: { "X-TEST": req.headers.get("X-TEST") }});
const data = await beresp.json();
const responseBody = JSON.stringify(data);

const res = new Response(responseBody, {
  status: beresp.status,
  headers: { "content-type": "application/json" }
});

res.headers.set("cache-control", "public, s-maxage=60");
res.headers.set("vary", "X-TEST");

ctx.waitUntil(cache.put(cacheKey, res.clone()));

return res;


The response from Cloudflare Workers at this time is shown in the first image. Because this is the first request, it has not hit the cache yet.
However, the second one is the response header when the cache is hit.

Contrary to my intention, max-age=14400 is given to
cache-control
.

Also, when maxage=60 is used instead of s-maxage, maxage=14400 is overwritten in the same way.

I would like a reason for this behavior and documentation.

Also, I have specified s-maxage=60, so I expect a HIT to be returned for 1 minute, but for what reason would the request be routed to origin?
2023-08-19_1.20.11.png
2023-08-19_1.21.18.png
Was this page helpful?