
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
@cacheable/net
Advanced tools
High Performance Network Caching for Node.js with fetch, request, http 1.1, and http 2 support
High Performance Network Caching for Node.js with fetch support and HTTP cache semantics
Features:
fetch from undici with caching enabled via cacheableget, post, put, patch, delete, and head for easier developmenthttp-cache-semanticsstringify and parse functionscaching optionnpm install @cacheable/net
import { CacheableNet } from '@cacheable/net';
const net = new CacheableNet();
// Simple GET request with caching
const response = await net.get('https://api.example.com/data');
console.log(response.data);
// POST request with data
const result = await net.post('https://api.example.com/users', {
name: 'John Doe',
email: 'john@example.com'
});
// Using fetch directly with caching
const fetchResponse = await net.fetch('https://api.example.com/data', {
method: 'GET',
headers: {
'Authorization': 'Bearer token'
}
});
You can provide custom stringify and parse functions for handling data serialization. This is particularly useful when working with complex data types that JSON doesn't natively support:
import { CacheableNet } from '@cacheable/net';
import superjson from 'superjson';
// Using superjson for enhanced serialization
// Supports Dates, BigInt, RegExp, Set, Map, Error and more
const net = new CacheableNet({
stringify: (value) => superjson.stringify(value),
parse: (text) => superjson.parse(text)
});
// Now you can work with complex data types
const response = await net.post('https://api.example.com/data', {
timestamp: new Date(),
userId: BigInt(12345),
pattern: /[a-z]+/gi,
metadata: new Map([['key', 'value']]),
tags: new Set(['important', 'urgent'])
});
// Or provide per-request custom serialization
const result = await net.get('https://api.example.com/data', {
parse: (text) => {
// Custom parsing with superjson for this request only
return superjson.parse(text);
}
});
You can control caching behavior at multiple levels:
import { CacheableNet } from '@cacheable/net';
const net = new CacheableNet({
httpCachePolicy: true // Enable HTTP cache semantics globally (default)
});
// GET requests are cached by default
const data1 = await net.get('https://api.example.com/data');
// Disable caching for a specific GET request
const data2 = await net.get('https://api.example.com/data', {
caching: false
});
// POST requests are NOT cached by default
const result1 = await net.post('https://api.example.com/data', { value: 1 });
// Enable caching for a specific POST request
const result2 = await net.post('https://api.example.com/data', { value: 1 }, {
caching: true
});
The main class that provides cached network operations.
interface CacheableNetOptions {
cache?: Cacheable | CacheableOptions; // Cacheable instance or options
httpCachePolicy?: boolean; // Enable HTTP cache semantics (default: true)
stringify?: (value: unknown) => string; // Custom JSON stringifier (default: JSON.stringify)
parse?: (value: string) => unknown; // Custom JSON parser (default: JSON.parse)
}
All methods accept request options of type FetchOptions (excluding the cache property which is managed internally):
The FetchOptions type extends the standard fetch RequestInit options with additional caching controls:
type FetchOptions = Omit<RequestInit, 'cache'> & {
cache?: Cacheable; // Optional cache instance (if not provided, no caching)
httpCachePolicy?: boolean; // Override instance-level HTTP cache setting
};
The NetFetchOptions type (used by all HTTP method helpers) provides additional control:
type NetFetchOptions = {
caching?: boolean; // Enable/disable caching for this request
stringify?: (value: unknown) => string; // Custom JSON stringifier
parse?: (value: string) => unknown; // Custom JSON parser
} & Omit<FetchOptions, 'method' | 'cache'>;
Note: When using the CacheableNet methods, you don't need to provide the cache property as it's automatically injected from the instance.
By default:
caching: true in the optionscaching: false in the optionsYou can contribute by forking the repo and submitting a pull request. Please make sure to add tests and update the documentation. To learn more about how to contribute go to our main README https://github.com/jaredwray/cacheable. This will talk about how to Open a Pull Request, Ask a Question, or Post an Issue.
FAQs
High Performance Network Caching for Node.js with fetch, request, http 1.1, and http 2 support
The npm package @cacheable/net receives a total of 277 weekly downloads. As such, @cacheable/net popularity was classified as not popular.
We found that @cacheable/net demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.