Cache API how long is the maximum allowed time for a worker to cache the response on edge

How long can a worker cache a response on the edge for.

I can’t see any documenation stating the maxmimum allowed time.

cacheTtl: 31536000 //1year?

let response = await fetch(request, {cf: {cacheTtl: 31536000}})

I would love to know thank you.

And to piggyback off of that question. Is there a minimum ttl?

minimum = 0
practical minimum = 10000ms
maximum = 1 year maybe, but not the best practice.
ideal maximum = 30 days

For static files that never change it is good practice. To give them a long TTL.

I have put the code above in my worker but unfortunately no idea testing static files how long they are going to be in the edge cache for.

The following are minimum.

0 to cache but to expire immediately.
-1 to not cache at all.

Note that your code is not caching the Response, it is just caching the Request.
You need to do something like this:

1 Like