Skip to content

Commit 63bb42f

Browse files
Issue 1424 - Latest flask-compress (1.6.0) breaks Dash (#1426)
1 parent a94fdc7 commit 63bb42f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to `dash` will be documented in this file.
33
This project adheres to [Semantic Versioning](https://semver.org/).
44

5+
## Unreleased
6+
### Fixed
7+
- [#1426](https://github.com/plotly/dash/pull/1426) Fix a regression caused by `flask-compress==1.6.0` causing performance degradation on server requests
8+
59
## [1.16.2] - 2020-09-25
610
### Fixed
711
- [#1415](https://github.com/plotly/dash/pull/1415) Fix a regression with some layouts callbacks involving dcc.Tabs, not yet loaded dash_table.DataTable and dcc.Graph to not be called

dash/dash.py

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import flask
2121
from flask_compress import Compress
2222
from werkzeug.debug.tbtools import get_current_traceback
23+
from pkg_resources import get_distribution, parse_version
2324

2425
import plotly
2526
import dash_renderer
@@ -49,6 +50,8 @@
4950
from . import _validate
5051
from . import _watch
5152

53+
_flask_compress_version = parse_version(get_distribution("flask-compress").version)
54+
5255
# Add explicit mapping for map files
5356
mimetypes.add_type("application/json", ".map", True)
5457

@@ -283,6 +286,16 @@ def __init__(
283286
else:
284287
raise ValueError("server must be a Flask app or a boolean")
285288

289+
if (
290+
self.server is not None
291+
and not hasattr(self.server.config, "COMPRESS_ALGORITHM")
292+
and _flask_compress_version >= parse_version("1.6.0")
293+
):
294+
# flask-compress==1.6.0 changed default to ['br', 'gzip']
295+
# and non-overridable default compression with Brotli is
296+
# causing performance issues
297+
self.server.config["COMPRESS_ALGORITHM"] = ["gzip"]
298+
286299
base_prefix, routes_prefix, requests_prefix = pathname_configs(
287300
url_base_pathname, routes_pathname_prefix, requests_pathname_prefix
288301
)

requires-install.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Flask>=1.0.2
2-
flask-compress==1.5.0
2+
flask-compress
33
plotly
44
dash_renderer==1.8.2
55
dash-core-components==1.12.1

0 commit comments

Comments
 (0)