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

Hishel stores no-store data #226

Open
douglas-raillard-arm opened this issue Apr 17, 2024 · 2 comments
Open

Hishel stores no-store data #226

douglas-raillard-arm opened this issue Apr 17, 2024 · 2 comments

Comments

@douglas-raillard-arm
Copy link

Hishel used with AsyncInMemoryStorage() accumulates data in memory, even though the request was done using extensions={'cache_disabled': True} and the response had Cache-Control: no-store set. This leads to an out-of-memory situation in my case as the data is quite large.

@douglas-raillard-arm
Copy link
Author

Actually it may not store as such, but maybe hishel is simply not preserving non-cached streaming responses and collects in memory the entire data set, even if it will not be cached. The memory steadily grows during the request, then goes back to a low level after the request is finished.

@karpetrosyan
Copy link
Owner

Hi!

I think we do not store responses if the cache was disabled using cache_disabled extension.
As you mentioned, hishel reads the response data even when it should not be stored.

Here is where we do it in hishel:

await httpcore_regular_response.aread()
await httpcore_regular_response.aclose()
if self._controller.is_cachable(request=httpcore_request, response=httpcore_regular_response):
await self._storage.store(
key,
response=httpcore_regular_response,
request=httpcore_request,
)

Simply, moving these two lines into the if should resolve the problem

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

2 participants