Skip to content
New issue

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

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

Already on GitHub? # to your account

[Question] Method post is caching? #57

Closed
victorparra96 opened this issue Mar 30, 2022 · 6 comments
Closed

[Question] Method post is caching? #57

victorparra96 opened this issue Mar 30, 2022 · 6 comments

Comments

@victorparra96
Copy link

I try cache for fastapi but i not know if post method is caching, or is only for get method

@long2ice
Copy link
Owner

Just for get, reference http protocol

@kishvanchee
Copy link

kishvanchee commented May 3, 2022

@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

@aiwhoo
Copy link

aiwhoo commented Oct 27, 2022

Can we move this into the main branch? Definitely seems useful.

@gegnew
Copy link

gegnew commented Nov 10, 2022

agreed, would definitely find this useful

@mkdir700
Copy link
Contributor

@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.

@mjpieters
Copy link
Collaborator

We should probably consolidate this into a single issue. I've commented on #75, which is the same issue.

@mjpieters mjpieters closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants