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
The latter is the gzipped version while the former is already uncompressed. This causes issues when creating a new response from the cached data, because the headers indicate the response is gzipped/has a certain length, but the actual content is already rendered/uncompressed.
Hi, I ran into an issue while using the
cache_response
decorator.Specifically when trying to cache a compressed response using both a custom
gzip
decorator and thecache_response
one, similar to:My gzip decorator does something similar to what django's
gzip_page
decorator does.I noticed the problem stems from https://github.com/chibisov/drf-extensions/blob/0.4.0/rest_framework_extensions/cache/decorators.py#L74 caching the
Response.rendered_content
rather than theResponse.content
.The latter is the gzipped version while the former is already uncompressed. This causes issues when creating a new response from the cached data, because the headers indicate the response is gzipped/has a certain length, but the actual content is already rendered/uncompressed.
This was working as expected in drf-extensions==0.3.1 where the whole response object was cached. I've fixed this in drf-extensions==0.4.0 by subclassing
cache_response
and actually caching theResponse.content
.I can send a PR for this but wanted to check I wasn't missing anything before doing so. Please let me know if I can provide any more information.
EDIT: Sorry, pressed "Submit" too soon.
EDIT 2: Formatting.
The text was updated successfully, but these errors were encountered: