-
Notifications
You must be signed in to change notification settings - Fork 49
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
Requests with POST is not cached #2
Comments
POST requests are not supported, and I think to fetch data with POST request was not a good idea... |
closed |
Hi @kuitos I think sometimes it makes sense to cache POST requests. One example I can find is
It returns Jack and Rose's mailtip. BTW, thanks for brining us this library! |
This api was served by graphql? |
No, it is REST API. Sorry, forget the link. https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/user_getmailtips |
@hongbo-miao |
@kuitos got it, thank you for the info! |
For the sake of discussion: Technically the HTTP/1.1 RFC document says that POST is a cacheable method: https://tools.ietf.org/html/rfc7231#section-4.2.3. In my case I need to send data to be analyzed (as a big JSON) to the server in order to get a response (which can take several minutes to process) - I'd like to cache that response as long as the request body is the same. I don't mind having to manually forceUpdate, but it would be super nice to be able to cache the response to a POST. I guess it might be a big change though, since it looks like this library is really structured around GETs and the buildURL helper - how would we handle the POST body if we were to update this project, right? Anyway I'd like to help but it's a bit over my head. If anyone can give me a few pointers, I can work on it and try to contribute. Thoughts? |
@brendanmatkin |
@kuitos ok thanks! I'll chew on it. For now I'm thinking (since it seems to be needed in only a few edge cases), that checking if the body has changed happens in the implementation (maybe using force-update), and axios-extensions just allows us to use POST as a method. (I guess this is probably what you mean by "define the caceable logic by himself"). This would probably be way easier to build but might lead to some confusion when things are automatically caching even though something has changed... maybe we add another option to flag it as manual caching logic? |
@kuitos I feel a generic library like "axios-extensions" should cater to all the methods that axios supports without introducing any subjective presumptions about any methods. It should be on the user to determine which rule of theory they follow. It should let the user choose ingredients of the hash e.g. query, params, body, headers etc. You could just have "cache":true and additional hashing inputs from user. Doing that would give this library a more generic, free from any assumptions. |
@kuitos have a look a cachios, it has a nice implementation of it. mostly due to being able to cache the post request/response with a custom key you want |
I've created an package at npm to cache post and get request, just look for axios-post-cache |
Excuse me, has this function been added? |
POST requests are not cached. It is requested for every request. Is there some limitation or Do I need to configure it differently?
The text was updated successfully, but these errors were encountered: