
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
cache-api-keyval
Advanced tools
Browser Cache API key/value store with +50MB capacity, expiration and JSON object data-type storage.
Fast and tiny key/value store with +50MB storage capacity in most browsers, expiration and JSON object data-type support.
Cache API is currently available in Chrome >= 40, Firefox >=39 and Opera >= 27.
Safari and Edge recently introduced support for it.
Info by Google: https://developers.google.com/web/fundamentals/instant-and-offline/web-storage/cache-api
<script><script src="dist/cache-api-keyval-iife.js"></script>
// set JSON object data
CacheApiDB.set('key', { json: 'object' });
// set text data with expiration in 24 hours
CacheApiDB.set('key2', 'string', 86400);
// get data from cache
CacheApiDB.get('key').then(function(json) {
console.log('json object', json);
});
// delete key from database
CacheApiDB.del('key2');
// clear database
CacheApiDB.clear();
// prune expired cache entries
CacheApiDB.prune();
import { set } from 'cache-api-keyval';
set('hello', 'world');
set('foo', 'bar', 3600); // expire in 1 hour
The data is stored in JSON format and supports big data.
All methods return promises:
import { set } from 'cache-api-keyval';
set('hello', 'world')
.then(() => console.log('It worked!'))
.catch(err => console.log('It failed!', err));
import { get } from 'cache-api-keyval';
// logs: "world"
get('hello').then(val => console.log(val));
If there is no 'hello' key, then val will be undefined.
import { keys } from 'cache-api-keyval';
// logs: ["hello", "foo"]
keys().then(keys => console.log(keys));
import { del } from 'cache-api-keyval';
del('hello');
import { clear } from 'cache-api-keyval';
clear();
import { prune } from 'cache-api-keyval';
prune();
The prune method clears all expired keys.
By default, the methods above use a default keyval store. You can create your own store, and pass it as an additional parameter to any of the above methods:
import { get, set } from 'cache-api-keyval';
set('foo', 'bar', 'custom-store');
get('foo', 'custom-store');
That's it!
With thanks to idb-keyval. The v2.0.0 code structure has been copied from idb-keyval.
npm install --save cache-api-keyval
Now you can require/import cache-api-keyval:
import { get, set } from 'cache-api-keyval';
<script>dist/cache-api-keyval.mjs is a valid JS module.dist/cache-api-keyval-iife.js can be used in browsers that don't support modules. CacheApiDB is created as a global.dist/cache-api-keyval-iife.min.js As above, but minified.FAQs
Browser Cache API key/value store with +50MB capacity, expiration and JSON object data-type storage.
We found that cache-api-keyval demonstrated a not healthy version release cadence and project activity because the last version was released 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
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.