mistval / node-fetch-cache

Node-fetch with built-in response caching.
MIT License
51 stars 8 forks source link

feature request - add option to memory and disk caches to cache responses based on response headers #16

Closed kran6a closed 2 years ago

kran6a commented 2 years ago

When using fetch in the browser only responses returning an appropriate cache-control header are cached. This is useful when dealing with uncachable responses or responses that expire at a different (or unpredictable) rate.

By adding this option we spare entries from being vacuumed unlike using a interval-based approach since the cache-control header states how long the response can be cached and we know exactly which responses are stale and which are still fresh.

mistval commented 2 years ago

Hello, have you considered make-fetch-happen? It might be better for you since it supports caching based on headers.

mistval commented 2 years ago

Closing: make-fetch-happen is likely a better choice if you need caching based on response header semantics. This module is intended to cache everything. (I think you can even make make-fetch-happen cache everything too if you use the force-cache option, which might make it an all-around better choice than this module, but I haven't tested how that works)