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

allow forceUpdate on POST requests #46

Closed
peters313 opened this issue Mar 4, 2019 · 4 comments
Closed

allow forceUpdate on POST requests #46

peters313 opened this issue Mar 4, 2019 · 4 comments

Comments

@peters313
Copy link

would it be possible to allow a forceUpdate (or clear the cache for that matter) to happen on a Post/Put/Delete request? that way if you do simply just local state updates when adding/updating/deleting on the ui but if the component were to mount again, it would see that the cache is no longer there and make the API request to generate a new cache

@kuitos
Copy link
Owner

kuitos commented Apr 10, 2019

duplicated with #2

@kuitos kuitos closed this as completed Apr 10, 2019
@AndrewCraswell
Copy link

AndrewCraswell commented Jul 24, 2019

@kuitos This is not a duplicate of #2. What I believe @peters313 is saying, is that certain methods against an endpoint should remove an existing GET from the cache.

For example, if I hit the endpoint like so:
GET /api/profile/ [Real request]
POST /api/profile/ [Should remove the Get from the cache since the object has likely changed]
GET /api/profile/ [Real request]
GET /api/profile/ [Pulls from cache]

This could get more advanced by checking the Status code response, but at the very least, PUT, POST, and DELETE methods are expected to modify the resource, so we should throw away any cached GET.

@AndrewCraswell
Copy link

For reference, seems that axios-cache-adapter operates like this by default as described here.

@kuitos
Copy link
Owner

kuitos commented Jul 24, 2019

sorry for my misunderstand, I think u could control your cache by yourself, as not every project follow the rest api spec, related issue #52

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

3 participants