You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When disabling the cache, the cache backend is still being updated when making requests.
The problem is in the CacheBackend#request method, that creates actions based on the request itself.
This does not take into account whether the cache is disabled, and thus skip_read and skip_write are left at false.
Subsequently, the request is retrieved from the cache backend, but the get_response() method checks whether the response is cacheable, which takes the disabled state of the cache into account and deletes as a consequence the response from the cache.
Finally, the request is made to the real remote resulting in the expected behavior, but unfortunately, the cache has been modified in the process and unnecessary calls have been made.
Expected behavior
when session.disabled() is being used, the cache is completely disabled, both for reading requests as for writing responses.
Steps to reproduce the behavior
Simple testcase:
async with self.init_session() as session:
response = await session.request("GET", httpbin('cache/0'))
assert response.from_cache is False
assert await session.cache.responses.size() == 1
async with session.disabled():
response = await session.request("GET", httpbin('cache/0'))
assert response.from_cache is False
assert await session.cache.responses.size() == 1
Workarounds
Create a new session instead.
Environment
aiohttp-client-cache version: 0.9.1
Python version: 3.10
The text was updated successfully, but these errors were encountered:
The problem
When disabling the cache, the cache backend is still being updated when making requests.
The problem is in the CacheBackend#request method, that creates actions based on the request itself.
This does not take into account whether the cache is disabled, and thus skip_read and skip_write are left at false.
Subsequently, the request is retrieved from the cache backend, but the get_response() method checks whether the response is cacheable, which takes the disabled state of the cache into account and deletes as a consequence the response from the cache.
Finally, the request is made to the real remote resulting in the expected behavior, but unfortunately, the cache has been modified in the process and unnecessary calls have been made.
Expected behavior
when
session.disabled()
is being used, the cache is completely disabled, both for reading requests as for writing responses.Steps to reproduce the behavior
Simple testcase:
Workarounds
Create a new session instead.
Environment
0.9.1
3.10
The text was updated successfully, but these errors were encountered: