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

Caching of POST request, but dependent on data/json #211

Open
blueyed opened this issue Dec 6, 2019 · 1 comment
Open

Caching of POST request, but dependent on data/json #211

blueyed opened this issue Dec 6, 2019 · 1 comment

Comments

@blueyed
Copy link

blueyed commented Dec 6, 2019

I'd like to cache responses for POST requests, but only for matching data / json (similar to params have to match for GET requests).

This however does not appear to be possible easily, is it?

Related code: https://github.com/ionrock/cachecontrol/blob/7a198b41a14ac92cf3766599009326165dcc99cd/cachecontrol/controller.py#L125-L148

  • you cannot "encode" it in the request_url, since that only gets request.url (and would be too long anyway etc)
  • the cache lookup also gets the "cache_url" only (not the whole request)
  • the serializer then could return False, but it would mean that there's a misleading log warning, and that only the latest (matching) response would be cached
@blueyed
Copy link
Author

blueyed commented Dec 27, 2019

Note that requests-cache uses the request.body with the cache key: https://github.com/reclosedev/requests-cache/blob/master/requests_cache/backends/base.py#L218-L233

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