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.

Feature Request: async cache-busting

See original GitHub issue

Request

The ability to empty <Select.Async/>'s cache.

Use Case

We have a fairly search endpoint with parent-child data, where we only want to reveal the child data when the parent value is already “enabled” somewhere.

Example: there is a location ‘New York’ in USA and ‘York’ in the UK. When supplying ‘York’ to our search API, it will return nothing if neither USA or UK are enabled, [New York] when USA is enabled, and [New York, York] when both USA and UK are enabled.

The problem is that because the search string is the same, the smart cache prevents the new request from being made.

Proposed Interface(s)

1. Second argument to loadOptions()

Something like invalidateCache: boolean. Pretty straightforward. For future proofing, maybe an options object would be good as well.

2. Allow refs to provide access to an instance method invalidateCache()

Would instantly empty the cache. This method provides the most flexibility but is also a bit messy and imperative. A similar approach is used in react-virtualized forceUpdateGrid().

<Select.Async ref={node => this.Async = node}/>

// when desired
this.Async.invalidateCache();

It’s a pretty trivial feature to implement, so depending on how acceptable the proposed interfaces are, I can send a PR asap. Thanks! 😃

(Question re: v2 – are releases for v1 still planned / PRs for v1 still accepted?)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
oudouljcommented, Jul 1, 2019

I use v3.0.4 and I’m struggling with some kind of funky behavior probably due to the cache. I have cacheOptions={false} in an async select being populated through fetch/promise calls but it does not seem to be doing what its name says. The console.log shows the correct data at each call but the list is populated with partly wrong data 😕 Any update on either a fix or a workaround on this matter ? Thanks!

1reaction
timhwang21commented, Jul 26, 2018

This issue is resolved for me, so closing this. Thanks all!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cache Busting - Advanced Ads
AJAX Cache busting uses an AJAX call (admin-ajax.php) to load the correct ad. This method needs more performance but works with all dynamic...
Read more >
Cache Busting a React App - DEV Community ‍ ‍
TL;DR - SemVer your app and generate a meta.json file on each build that won't be cached by the browser. Invalidate cache and...
Read more >
How to conditionally cache bust an API in workbox
Example, below config caches feature-flags. I am trying to cache bust it when the page sends a request to "updateTests". workbox configuration ...
Read more >
Advanced topics on caching in Apollo Client
In some cases, a query requests data that already exists in the cache under a different reference. For example, your UI might have...
Read more >
Effectively using HTTP Caching, Cache Busting, and a CDN
“Caching” refers to a browser saving a file locally, then reusing it later instead of re-requesting the same asset from the server again....
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