Gathering detailed insights and metrics for webext-storage-cache
Gathering detailed insights and metrics for webext-storage-cache
Gathering detailed insights and metrics for webext-storage-cache
Gathering detailed insights and metrics for webext-storage-cache
Cache values in your Web Extension and clear them on expiration. Also includes a memoize-like API to cache any function results automatically
npm install webext-storage-cache
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (55.94%)
TypeScript (44.06%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
83 Stars
101 Commits
4 Forks
3 Watchers
3 Branches
4 Contributors
Updated on May 27, 2025
Latest Version
6.0.3
Package Id
webext-storage-cache@6.0.3
Unpacked Size
18.10 kB
Size
5.98 kB
File Count
11
NPM Version
10.8.1
Node Version
22.3.0
Published on
Jul 01, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Cache values in your Web Extension and clear them on expiration. Also includes a memoize-like API to cache any function results automatically.
chrome.storage
APIsstorage
: "The extension caches some values into the local storage"alarms
: "The extension automatically clears its expired storage at certain intervals"You can download the standalone bundle and include it in your manifest.json
.
Or use npm
:
1npm install webext-storage-cache
This module requires the storage
permission and it’s suggested to also use alarms
to safely schedule cache purging:
1/* manifest.json */ 2{ 3 "permissions": [ 4 "storage", 5 "alarms" 6 ], 7 "background": { 8 "scripts": [ 9 /* Remember to include/import it in the background to enable expired cache purging */ 10 "webext-storage-cache.js" 11 ] 12 } 13}
1import {CachedValue} from 'webext-storage-cache'; 2 3const item = new CachedValue('unique', { 4 maxAge: { 5 days: 3, 6 }, 7}); 8 9(async () => { 10 if (!(await item.isCached())) { 11 const cachableItem = await someFunction(); 12 await item.set(cachableItem); 13 } 14 15 console.log(await item.get()); 16})();
The same code could also be written more effectively with CachedFunction
:
1import {CachedFunction} from 'webext-storage-cache'; 2 3const cachedFunction = new CachedFunction('unique', { 4 updater: someFunction, 5 maxAge: { 6 days: 3, 7 }, 8}); 9 10(async () => { 11 console.log(await cachedFunction()); 12})();
isCached
/get
/set
globalCache
- Global helpers, documented belowlegacy
- The previous Map-like API, documented below, deprecatedClears the cache. This is a special method that acts on the entire cache of the extension.
1import {globalCache} from 'webext-storage-cache'; 2 3document.querySelector('.options .clear-cache').addEventListener('click', async () => { 4 await globalCache.clear() 5})
The API used until v5 has been deprecated and you should migrate to:
CachedValue
for simple cache.get
/cache.set
calls. This API makes more sense in a typed context because the type is preserved/enforced across calls.CachedFunction
for cache.function
. It behaves in a similar fashion, but it also has extra methods like getCached
and getFresh
You can:
cache.function
) by importing webext-storage-cache/legacy.js
(until v7 is published)1import cache from "webext-storage-cache/legacy.js"; 2 3await cache.get('my-url'); 4await cache.set('my-url', 'https://example.com');
The documentation for the legacy API can be found on the v5 version of this readme.
MIT © Federico Brigante
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More