A Node.js library that creates a full Content-Type header string from a MIME type or file extension, with LRU caching of results. Version 1.0+ uses the same underlying database as mime-types but adds an in-memory cache (default cache size 100) to avoid repeated lookups. Release cadence is low, updated primarily for dependency bumps and Node.js version support. Differentiator: provides cached content-type lookups, improving performance when the same extensions are queried multiple times (e.g., in HTTP servers).
npm install cache-content-typeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows import, type lookup with extension, MIME type, and performance of cache.
Replace 'import contentType from "cache-content-type"' with 'import { getType } from "cache-content-type"'.Upgrade Node.js to >=18.0.0 or stick with v1.x.
For larger caches, consider using mime-types directly or roll your own caching layer.
Check documentation for current usage.
Change to named import: import { getType } from 'cache-content-type';Run 'npm install cache-content-type' and ensure the module is in node_modules.
Check the return value: if getType returns false, handle gracefully (e.g., default to 'application/octet-stream').