-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding an IndexedDB Storage #669
Comments
Hey! This would be an awesome feature! Up to a PR? |
My only limitation here is to only merge PRs passing CI with added unit tests, anything else should be fine :) |
With pleasure. I'll do it in the next couple of days. |
Hey! I have it up and running. But there is an issue while writing the key value pair to the database. The set method is only receiving an empty object: "{"state":"loading","previous":"empty"}" |
@lucajung Without seeing the code I cannot help with. Open a draft PR please. |
Actually, it's already possible with https://www.npmjs.com/package/idb-keyval which I happen to use for a long time. import axios from "axios";
import { buildStorage, setupCache } from "axios-cache-interceptor";
import { clear, del, get, set } from "idb-keyval";
setupCache(axios, {
storage: buildStorage({
async find(key) {
let value;
try {
value = await get(key);
if (value != null) {
value = JSON.parse(value);
}
} catch (err) {
log.warn(err);
}
return value;
},
async set(key, value) {
try {
await set(key, JSON.stringify(value));
} catch (err) {
log.warn(err);
}
},
async remove(key) {
try {
await del(key);
} catch (err) {
log.warn(err);
}
}
})
}); |
Caching huge files which exceed the localstorage (5-10MB) are currently not cacheable.
IndexedDB might be the only solution to cache those responses in modern Web browsers.
The text was updated successfully, but these errors were encountered: