phpguy
phpguy

Reputation: 17

Angular update cached http response on demand

I'm using NgNeat Cashew library for caching certain APIs (local storage) in my Angular application, so far it's working great, I stumbled upon a scenario which one of the cached API response might be updated randomly but not frequently by the users on demand and since the API is not directly in my application (i.e. update is triggered by a user action which is not in my application, my application just consumes the API) how do I tell the library there's an update in the http response of the cached API and update the cache?

Thanks in advance for the help!

https://github.com/ngneat/cashew

My implementation:

   return this.http.get(ApiEndpoints.getRoles, {
  context: withCache({
    version: 'v1',
    key: 'APIRoles',
  })
}

Upvotes: 0

Views: 197

Answers (1)

Tal Hayoun
Tal Hayoun

Reputation: 76

I don't see how cache can be notified that it changed when it happens on another site. I suppose the only option for that scenario is either not use cache for that request or lower the ttl (which is still not guranteed to be updated)

Upvotes: 1

Related Questions