Add ability to clear/disable selector cache
See original GitHub issueThere’s some cases where you don’t want responses to be cached, because they depend on the currently logged-in user. If the user logs out, it’s a security issue for their data to be cached. It would be good to have some way to clear the cached values on log out.
What’s the recommended way to handle this situation?
export const selector_user_first_name = selector<string>({
key: 'user_first_name',
get: async () => {
return await (await fetch('/User/FirstName')).text();
}
});
export const LogOut = () => {
await fetch('/User/Logout', { method: 'POST' });
clearSelector(selector_user_first_name );
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Magento 2 Clear Cache: How to Flush, Enable and Disable ...
Go to System · Access Cache Management · Select all unnecessary cache types · Open the Actions drop-down menu (on the left) ·...
Read more >Turn on Cached Exchange Mode - Microsoft Support
Cached Exchange Mode is the default when you add an Exchange or Microsoft 365 ... Exchange Mode, repeat the steps, but clear Use...
Read more >Disabling Chrome cache for website development
The Chrome DevTools can disable the cache. Right-click and choose Inspect Element to open the DevTools. Or use one of the following keyboard...
Read more >How to Clear Your Cache in WordPress (Step by Step)
Simply go to Settings » WP Super Cache in your WordPress admin dashboard, and then click the 'Delete Cache' button in the 'Delete...
Read more >How to Clear Cache for All Major Browsers - Kinsta
However, many situations warrant the clearing of all cache data. In Chrome, select the Advanced tab in the Clear browsing data window. Now,...
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 FreeTop 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
Top GitHub Comments
@csantos42 is working on exactly this.
@drarmstr Selector cache policies do not fully address this issue. As far as I can tell from the docs, it is not possible to disable or imperatively clear a cache. We have some unit tests where cached selector data is bleeding between tests (see issue https://github.com/facebookexperimental/Recoil/issues/981)
There is no cache strategy of “none”. Also a cache strategy of
{ eviction: 'lru', maxSize: 0 }
does not disable caching.