diff --git a/src/fastapi_redis_cache/cache.py b/src/fastapi_redis_cache/cache.py index 5257a14..6b29dbb 100644 --- a/src/fastapi_redis_cache/cache.py +++ b/src/fastapi_redis_cache/cache.py @@ -39,6 +39,8 @@ async def inner_wrapper(*args, **kwargs): 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.