The way i&#x27;ve seen it done is something like this:<p>* Cache never automatically expires, but you do have some notion of staleness
* Whenever you request data, you get it from the cache (if it exists), and check for staleness, so you cached data needs to know when it was cached.
* Return the data as usual, but if the data was also stale, you fire off a worker to update the cached data.
* If you have lots of requests happening at the same time, you have a system for seeing if a worker already exists, to ensure that you only create one (for each piece of cached data).
* For the time it takes for the worker to complete, you have to be okay with serving stale data, in most cases this is okay.<p>There&#x27;s an edge case missed here, which is what to do when the cache is empty (either because it&#x27;s one of the first requests, or because the cached data has been evicted). That&#x27;s up to you, depending on your use case. You can basically either return a default value, you can pre-warm your cache, or you can let the requests hang until the data is ready.