Open jaepetto opened 2 years ago
+1
@jaeger-2601 I made a PR for that. In the meantime, you can apply the below patch:
--- fastapi_redis_cache_cache_old.py 2022-10-25 16:24:43.000000000 +0200
+++ fastapi_redis_cache_cache_new.py 2022-10-25 16:24:07.000000000 +0200
@@ -34,6 +34,8 @@
create_response_directly = not response
if create_response_directly:
response = Response()
+ if "content-length" in response.headers.keys():
+ del response.headers["content-length"]
redis_cache = FastApiRedisCache()
if redis_cache.not_connected or redis_cache.request_is_not_cacheable(request):
# if the redis client is not connected or request is not cacheable, no caching behavior is performed.
+1
@LittleRookie1706 This project seems to be abandoned by the maintainer. I suggest moving to fastapi-cache or you can apply @jaepetto's patch.
Thanks @jaeger-2601 for the tip about fastapi-cache. I'll probably move to it too.
The same exact code is raising exceptions when using the
@cache
decorator:This code raises the exception: "Too much data for declared Content-Length"
The same code runs well when I remove the
@cache
decorator (no surprise here), but also works well when the redis server is unavailable (forcing the caching mechanism to evaluate the code).Thanks in advance for any insight...
The stack trace is as below: