Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache not being cleared #104

Open
JonasDev17 opened this issue Nov 9, 2024 · 0 comments
Open

Cache not being cleared #104

JonasDev17 opened this issue Nov 9, 2024 · 0 comments

Comments

@JonasDev17
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

I have a requets that updates a resource on the server and I called pipe on the resulting observable with a tap operator where I cleared a cachebucket. After clearing said cachebucket I called my backend to fetch the updated resource. However I get the cached version back. I also tried with a 2 second delay but it would still return the cache version (even though I cleared the cachebucket using the manager). However I use cachebuckets all over the place and they work. What I realized though is that most of the time after saving I redirect the user to another place.

Now I managed to fix this by adding a cleareCachePredicate to my request:

withCache({
    bucket,
    clearCachePredicate: (_, request) => {
        return !bucket?.has(request.urlWithParams);
    },
})

this works but clearly something is broken.

Expected behavior

I would expect the http service to send a fresh request to the server and return the updated entity instead of the cashew cached version.

Minimal reproduction of the problem with instructions

As described above: send a request to get the entity first, then send a request to update the entity and pipe the resulting observable and clear the bucket using a tap operator and then right after, send another request to fetch the updated entity.

Environment


Angular version: 18.2.11

Browser:
- [x] Chrome (desktop) Version 130.0.6723.70 (Official Build) (64-bit)
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

Others:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant