diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a62a864e2..ded3b1b5a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `dash` will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). +## Unreleased +### Fixed +- [#1426](https://github.com/plotly/dash/pull/1426) Fix a regression caused by `flask-compress==1.6.0` causing performance degradation on server requests + ## [1.16.2] - 2020-09-25 ### Fixed - [#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 diff --git a/dash/dash.py b/dash/dash.py index cb3f7aae01..71ae894a24 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -20,6 +20,7 @@ import flask from flask_compress import Compress from werkzeug.debug.tbtools import get_current_traceback +from pkg_resources import get_distribution, parse_version import plotly import dash_renderer @@ -49,6 +50,8 @@ from . import _validate from . import _watch +_flask_compress_version = parse_version(get_distribution("flask-compress").version) + # Add explicit mapping for map files mimetypes.add_type("application/json", ".map", True) @@ -283,6 +286,16 @@ def __init__( else: raise ValueError("server must be a Flask app or a boolean") + if ( + self.server is not None + and not hasattr(self.server.config, "COMPRESS_ALGORITHM") + and _flask_compress_version >= parse_version("1.6.0") + ): + # flask-compress==1.6.0 changed default to ['br', 'gzip'] + # and non-overridable default compression with Brotli is + # causing performance issues + self.server.config["COMPRESS_ALGORITHM"] = ["gzip"] + base_prefix, routes_prefix, requests_prefix = pathname_configs( url_base_pathname, routes_pathname_prefix, requests_pathname_prefix ) diff --git a/requires-install.txt b/requires-install.txt index 3079287439..a507a14e2f 100644 --- a/requires-install.txt +++ b/requires-install.txt @@ -1,5 +1,5 @@ Flask>=1.0.2 -flask-compress==1.5.0 +flask-compress plotly dash_renderer==1.8.2 dash-core-components==1.12.1