Registry / testing / cypress-http-cache

cypress-http-cache

JSON →
library1.1.2jsnpmunverified

cypress-http-cache (v1.1.2) is an in-memory HTTP caching proxy for Cypress end-to-end test suites. It works by intercepting HTTP requests between Cypress and your web application, caching responses to dramatically speed up subsequent test runs, especially when the same assets are loaded across multiple test specs. This plugin is specifically designed to solve the problem of Cypress clearing the browser cache between test files. It is compatible with Cypress 10+ and is released under MIT. Key differentiators: minimal configuration (single function install), configurable cache size and stats reporting, optional diagnostic headers, support for detached mode (background process or remote proxy).

npm install cypress-http-cache
INSTALL
IMPORT
SIG · CYPRESS-HTTP-CACHE
C
cypress-http-cache
testingjavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

installHttpCache
const { installHttpCache } = require('cypress-http-cache');
const installHttpCache = require('cypress-http-cache');
The package exports a single named function. Using default import returns an object, which will cause a runtime error.
installHttpCache (ESM)
import { installHttpCache } from 'cypress-http-cache';
import * as httpCache from 'cypress-http-cache';
ESM import also uses named import. Star import returns a module object, not the function directly.
TypeScript types
import type { InstallHttpCacheOptions } from 'cypress-http-cache';
Package ships TypeScript types. The options type is exportable for type-checking config.

Configures Cypress to use an in-memory HTTP cache during E2E tests, with 50 MB cache and stats printed after the run.

// cypress.config.js const { defineConfig } = require('cypress'); const { installHttpCache } = require('cypress-http-cache'); module.exports = defineConfig({ e2e: { async setupNodeEvents(on, config) { return installHttpCache(on, config, { cacheSize: 50, stats: 'after:run', addCacheHeaders: true }); }, baseUrl: 'http://localhost:3000' } });
Debug
Known issues
breakingPackage requires Cypress version 10 or higher. Does not work with Cypress 9.x.
fix
Upgrade Cypress to v10+.
affects: <10.0.0
breakinginstallHttpCache MUST be called inside setupNodeEvents and the returned value MUST be passed to Cypress. Failure to return the modified config will cause the proxy to not start.
fix
Ensure you return the result of installHttpCache (or config returned from it) from setupNodeEvents.
affects: >=0.0.0
gotchaIn detached mode ('detached: true'), the plugin does NOT stop the proxy process when Cypress finishes. This can lead to orphaned proxy processes consuming memory.
fix
Either use detached mode only in CI with proper cleanup, or avoid detached mode for local runs.
affects: >=0.0.0
deprecatedThe 'after:spec' value for stats option is deprecated since v1.1.0 and will be removed in v2.0.0.
fix
Use 'after:run' or 'never' instead.
affects: >=1.1.0
Errors
Common errors & fixes
TypeError: installHttpCache is not a function
Using default import or incorrect require destructuring.
fix
Use `const { installHttpCache } = require('cypress-http-cache');`
Error: Cypress version is not compatible. Expected >=10.0.0
Running Cypress version older than 10.
fix
Upgrade Cypress to v10 or later.
Proxy not starting: setupNodeEvents must return the modified config object.
The installHttpCache call is not returned or the config is not returned from setupNodeEvents.
fix
Ensure your setupNodeEvents function ends with `return installHttpCache(on, config);`
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Amazon
1
Resources
cypress-http-cache — npm install cypress-http-cache · libregistry