{"id":44942,"library":"fetchache","title":"fetchache","description":"Cross-platform fetch wrapper that adds HTTP caching support to any fetch implementation using a key-value cache. Version 0.1.6 is the latest stable release. It follows HTTP Caching (RFC 7234) and Conditional Requests (RFC 7232) standards, allowing server-like caching behavior in non-browser environments (Node.js, workers). Unlike simple memoization, it respects Cache-Control headers, ETags, and expiration. Ships TypeScript types. Requires Node >= 16. Low release cadence; maintained by Ardatan/whatwg-node ecosystem.","status":"active","version":"0.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/ardatan/whatwg-node","tags":["javascript","typescript"],"install":[{"cmd":"npm install fetchache","lang":"bash","label":"npm"},{"cmd":"yarn add fetchache","lang":"bash","label":"yarn"},{"cmd":"pnpm add fetchache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Recommended fetch and Response polyfill for Node.js; otherwise must provide custom fetch/Response.","package":"@whatwg-node/fetch","optional":true}],"imports":[{"note":"Package is ESM-only; CommonJS require() will fail. Use named import.","wrong":"const fetchFactory = require('fetchache').fetchFactory","symbol":"fetchFactory","correct":"import { fetchFactory } from 'fetchache'"},{"note":"fetchache re-exports Response for convenience, but you must provide your own fetch implementation.","wrong":"import { Response } from '@whatwg-node/fetch'","symbol":"Response","correct":"import { Response } from 'fetchache'"},{"note":"You must pass both fetch and Response constructors, not just fetch. Otherwise errors occur.","wrong":"const fetchWithCache = fetchFactory({ fetch, cache })","symbol":"fetchWithCache","correct":"const fetchWithCache = fetchFactory({ fetch, Response, cache })"}],"quickstart":{"code":"import { fetchFactory } from 'fetchache';\nimport { fetch, Response } from '@whatwg-node/fetch';\n\nconst cache = new Map<string, string>();\nconst cacheImpl = {\n  get: async (key: string) => cache.get(key) ?? undefined,\n  set: async (key: string, value: string) => { cache.set(key, value); },\n};\n\nconst fetchWithCache = fetchFactory({ fetch, Response, cache: cacheImpl });\n\nconst response = await fetchWithCache('https://jsonplaceholder.typicode.com/todos/1');\nconst data = await response.json();\nconsole.log(data);","lang":"typescript","description":"Creates a cached fetch using an in-memory Map, demonstrating the minimal setup with @whatwg-node/fetch."},"warnings":[{"fix":"Always pass both fetch and Response. Use @whatwg-node/fetch for Node.js.","message":"Must provide both fetch and Response implementations; missing one causes cryptic errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Implement cache { get(key: string): Promise<string|undefined>; set(key: string, value: string): Promise<void> }.","message":"Cache implementation must match the expected interface: get and set with async string keys and values.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use import syntax or dynamic import(). Set 'type':'module' in package.json if running as CommonJS.","message":"Package is ESM-only; using require() throws 'ERR_REQUIRE_ESM'.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Understand that cache keys are derived from the request; do not rely on manual key generation.","message":"The cache key includes full URL and method; sensitive headers are not cached.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.6':23 '16':71 '7232':39 '7234':34 'add':8 'allow':41 'ardatan/whatwg-node':77 'behavior':46 'browser':50 'cach':10,21,32,45,60 'cache-control':59 'cadenc':74 'condit':36 'control':61 'cross':3 'cross-platform':2 'ecosystem':78 'environ':51 'etag':63 'expir':65 'fetch':5,14 'fetchach':1 'follow':30 'header':62 'http':9,31 'implement':15 'javascript':79 'key':19 'key-valu':18 'latest':26 'like':44 'low':72 'maintain':75 'memoiz':56 'node':70 'node.js':52 'non':49 'non-brows':48 'platform':4 'releas':28,73 'request':37 'requir':69 'respect':58 'rfc':33,38 'server':43 'server-lik':42 'ship':66 'simpl':55 'stabl':27 'standard':40 'support':11 'type':68 'typescript':67,80 'unlik':54 'use':16 'valu':20 'version':22 'worker':53 'wrapper':6","created_at":"2026-06-07T12:52:35.101894+00:00","updated_at":"2026-06-07T12:52:35.101894+00:00","problems":[{"fix":"Use @whatwg-node/fetch which exports a constructor-compatible fetch. Alternatively, wrap fetch using the factory pattern: const fetchFunc = (...args) => fetch(...args);","cause":"Passing a native fetch or a fetch that is not a constructor (e.g., from undici or cross-fetch).","error":"TypeError: fetch is not a constructor"},{"fix":"Change to import { fetchFactory } from 'fetchache' or use dynamic import().","cause":"Using require('fetchache') in a CommonJS file.","error":"ERR_REQUIRE_ESM"},{"fix":"Ensure cache implements { get: (key: string) => Promise<string | undefined> }.","cause":"Passed cache object without implementing the get method.","error":"TypeError: cache.get is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/ardatan/whatwg-node#readme","github":"https://github.com/ardatan/whatwg-node","docs":null,"changelog":null,"pypi":null,"npm":"fetchache","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}