Decorator for fetch that caches DNS resolutions per hostname, reducing DNS lookup overhead on repeated requests to the same host. Version 2.0.5 is the latest stable release; the project is a fork of @vercel/fetch-cached-dns with ongoing maintenance. Unlike other fetch wrappers, it transparently integrates with any fetch-compatible library (defaults to node-fetch) and handles redirects with an onRedirect callback. Suitable for high-throughput Node.js services where DNS latency is a bottleneck.
npm install fetch-cached-dnsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a fetch with cached DNS resolution and handles redirects via onRedirect callback.
Use require() instead of import. If you must use ESM, wrap with createRequire from 'module'.
Install node-fetch as a dependency, or pass an alternative fetch implementation.
No workaround; consider using a dedicated DNS caching library if TTL compliance is needed.
npm install node-fetch
Use require('fetch-cached-dns')(require('node-fetch')) instead of just require('fetch-cached-dns')