Bulk delete/edit multiple caches #639
-
I was trying to cache different pages of an API, for example, I was trying to cache the API |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hey @mohaali482, internally, all request URLs are hashed into a unique ID, making it impossible to do such thing like a https://www.npmjs.com/package/object-code However, you its possible to override your own key generator function to include the original id (only to keep uniqueness) + path (or something that you would use to group requests). https://axios-cache-interceptor.js.org/guide/request-id#custom-generator Something like this: const axios = setupCache(Axios, {
keyGenerator: buildKeyGenerator((request) => {
// Would return something like -2389472895my-group-identifier
return defaultKeyGenerator(request) + 'my-group-identifier';
}
}); And then, implement your own storage that deletes all keys ending with |
Beta Was this translation helpful? Give feedback.
Hey @mohaali482, internally, all request URLs are hashed into a unique ID, making it impossible to do such thing like a
startsWith
comparison, as both URLs will be transformed to completely different numbers.https://www.npmjs.com/package/object-code
However, you its possible to override your own key generator function to include the original id (only to keep uniqueness) + path (or something that you would use to group requests).
https://axios-cache-interceptor.js.org/guide/request-id#custom-generator
Something like this: