Remove old cached items
See original GitHub issueHi great library. Is there any way to delete old cache items to avoid using up lots of memory? For example in an app with lots of pages where you want to cache if the user presses back but they are unlikely to go back more than 10. Perhaps this could be written in user space by using mutate(key, null)
?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to Clear Cache on Android (And When You Should)
Older Android versions gave you the option to delete all cached files at once by going to Settings > Storage > Cached Data....
Read more >How to Clear Cache for All Major Browsers - Kinsta
One way to have cache clearing happen in the background is by adjusting the field to Remove History Items. You'll pick a certain...
Read more >Remove old cached items · Issue #4 · vercel/swr - GitHub
Hi great library. Is there any way to delete old cache items to avoid using up lots of memory? For example in an...
Read more >Shield Your Internet History: How to Clear Your Cache on Any ...
Go to the three-dot menu at the upper right of Chrome to select More tools > Clear browsing data. This will open a...
Read more >What is caching and how does it work? - Wired UK
As mentioned, deleting your cache will delete stored data, logins and more information so proceed with caution. Chrome.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @JakeCoxon that’s a good question! Yeah currently that’s the only way, because it might be dangerous to clear a cached key automatically: we don’t know if there’s any existing component still reading from that key.
To support that, we need to maintain a list for active keys (add/remove a key to the list when the SWR’s parent component is mounting/unmounted), which is not yet implemented.
Finally, we plan to export the cache APIs from the lib, and add options to the config soon. So you can override it with your own implementation like LRU cache, or just manipulate the cache object.
@shuding The counter middleware removes key from cache, however the values corresponding to
errorKey
andisValidatingKey
are still kept.