fastapi-cache
fastapi-cache copied to clipboard
[Question] Method post is caching?
I try cache for fastapi but i not know if post method is caching, or is only for get method
Just for get
, reference http protocol
@victorparra96 you can modify the decorator like this to enable caching for POST https://github.com/long2ice/fastapi-cache/blob/master/fastapi_cache/decorator.py#L53
if request.method not in {"GET", "POST"}:
return await func(request, *args, **kwargs)
I haven't personally experimented this with this library, but I have done this with https://github.com/a-luna/fastapi-redis-cache
Can we move this into the main branch? Definitely seems useful.
agreed, would definitely find this useful
@long2ice I believe that caching POST requests or any request method can be done because we can leverage the key_builder parameter. What do you think, if it's possible, I would like to submit a pull request for it.
We should probably consolidate this into a single issue. I've commented on #75, which is the same issue.