Registry / devops / d2l-fetch-simple-cache

d2l-fetch-simple-cache

JSON →
library2.1.3jsnpmunverified

Version 2.1.3 (stable, released 2021-07-29, maintenance mode). A d2l-fetch middleware that caches HTTP responses based on method, URL, and Authorization header. Ignores server Cache-Control directives; provides opt-in client-side caching with configurable TTL and method filtering. Depends on d2l-fetch; part of Brightspace ecosystem.

npm install d2l-fetch-simple-cache
INSTALL
IMPORT
SIG · D2L-FETCH-SIMPLE-C
D
d2l-fetch-simple-cache
devopsjavascriptv2.1.3
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.

fetchSimpleCache
import { fetchSimpleCache } from 'd2l-fetch-simple-cache';
const fetchSimpleCache = require('d2l-fetch-simple-cache');
Package is ESM-only; CommonJS require will not work.

Sets up the simple-cache middleware with a 5-minute TTL and makes a cached fetch request.

import d2lfetch from 'd2l-fetch'; import { fetchSimpleCache } from 'd2l-fetch-simple-cache'; d2lfetch.use({name: 'simple-cache', fn: fetchSimpleCache, options: { cacheLengthInSeconds: 300 }}); const response = await d2lfetch.fetch(new Request('https://example.com/api/data')); const data = await response.json(); console.log(data);
Debug
Known issues
breakingSince v2, the default export was removed; use named export fetchSimpleCache.
fix
Use named import: import { fetchSimpleCache } from 'd2l-fetch-simple-cache';
affects: >=2.0.0
deprecatedThis middleware ignores server Cache-Control directives, which may lead to stale caches and unexpected behavior.
fix
Consider using a more standards-compliant caching middleware if cache-control compliance is needed.
affects: all
Errors
Common errors & fixes
fetchSimpleCache is not a function
Importing default instead of named export
fix
Change to import { fetchSimpleCache } from 'd2l-fetch-simple-cache';
Cannot find module 'd2l-fetch-simple-cache'
Package not installed or incorrectly referenced
fix
Run 'npm install d2l-fetch-simple-cache' and ensure node_modules is present.
Upgrade
Version history
2.1.3latest on npm
Audit
Dependencies
d2l-fetchrequiredRequired peer dependency, as this is a middleware for d2l-fetch
Agent activity
8 hits · last 30 days
node
8
Resources
d2l-fetch-simple-cache — npm install d2l-fetch-simple-cache · libregistry