Open ryuapp opened 2 weeks ago
Just to add some background information, it's fair to say that cache middleware won't work properly with Deno because Cloudflare Workers respects the Cache-Control
header, but Deno doesn't.
That's why we need an option like this.
I don't use Deno, but wouldn't it make more sense to make Deno respect the Cache-Control
header with a Deno setting instead ? That is probably not what the issue is about though :thinking:
I don't use Deno, but wouldn't it make more sense to make Deno respect the Cache-Control header with a Deno setting instead ? That is probably not what the issue is about though 🤔
Deno is just a JavaScript runtime and will not extend Cache API. Since Cloudflare Workers is a service with CDN, it seems to be natural to consider extending the API.
What is the feature you are proposing?
Currently, with cache middleware, once it is cached, it is never updated. I'd like to keep the cache on the server side for short periods of time, but that's currently cumbersome. So, we introduce the concept of expiration time in cache middleware.
Add the
duration
option and store it in an internal header when the cache matches and check it, as in the example below.