question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove old cached items

See original GitHub issue

Hi 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
shudingcommented, Oct 29, 2019

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.

0reactions
piotr-czcommented, Oct 5, 2021

@shuding The counter middleware removes key from cache, however the values corresponding to errorKey and isValidatingKey are still kept.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found