colour-science / flask-compress

Compress responses of your Flask application.
MIT License
117 stars 27 forks source link

gzip not work with v1.12 #33

Closed blueloveTH closed 2 years ago

blueloveTH commented 2 years ago

I am not sure what happened. The gzip compress of my website works fine in v1.11. However, in v1.12 all files are uncompressed.

My usecase is basic as follows, where my static files locate in /web directory.

app = Flask(__name__, static_folder='web', static_url_path='')

app.config['COMPRESS_MIMETYPES'] = ['text/html', 'text/css', 'text/xml', 
                                    'application/json',
                                    'application/javascript', 'font/ttf', 'font/otf', 'application/octet-stream']

Compress(app)
alexprengere commented 2 years ago

I can reproduce, and I am pretty sure this is an unintended side effect of disabling the compression for streaming responses (see #30). Unfortunately looking at the code, I am not sure if there is an easy way of saying "disable compression for streaming responses, unless the response is for static content", from the response object. I might be wrong, so I will ping @gilad9366 @raphaeljolivet who were active in the other discussion.

cypres-it commented 2 years ago

How about an option switch COMPRESS_STREAMS (default False) until this is solved? This would help at least some people since not everyone actually needs streaming responses.