When using whitenoise for caching, which provides compression, binary types may include mimetypes, "text/", "application/json":
response.mimetype.startswith("text/")
response.mimetype == "application/json"
Assuming that Content-Encoding will be set (as whitenoise apparently does) this allows compression to be applied to assets which have mimetypes "text/" and "application/json", while allowing for uncompressed "text/" and "application/json" still to be served.
Not sure if this works for all use cases, but it currently appears to work for my workcase where whitenoise is performing compression of text/json files intended for caching, while still allowing text for html.
Coverage decreased (-0.2%) to 72.821% when pulling 14658ce60ecbe4a58a523d7585ed3c8a7e269e8d on monkut:master into 0c8d99ddbc297124d93c166652013abba50ee86e on Miserlou:master.
Description
Alternative solution to https://github.com/Miserlou/Zappa/issues/2080 intended to allow BINARY and text by making use of Content-Encoding header in the response.
When using whitenoise for caching, which provides compression, binary types may include mimetypes, "text/", "application/json":
Assuming that Content-Encoding will be set (as whitenoise apparently does) this allows compression to be applied to assets which have mimetypes "text/" and "application/json", while allowing for uncompressed "text/" and "application/json" still to be served.
About Content-Encoding: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
Not sure if this works for all use cases, but it currently appears to work for my workcase where whitenoise is performing compression of text/json files intended for caching, while still allowing text for html.
GitHub Issues
https://github.com/Miserlou/Zappa/issues/2080