Skip to content

Improve resource caching #973

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Oct 28, 2019
11 changes: 10 additions & 1 deletion dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,19 @@ def serve_component_suites(self, package_name, path_in_package_dist):
package.__path__,
)

return flask.Response(
response = flask.Response(
pkgutil.get_data(package_name, path_in_package_dist),
mimetype=mimetype,
)
response.add_etag()
(tag,) = response.get_etag()[:1]

request_etag = flask.request.headers.get('If-None-Match')

if '"{}"'.format(tag) == request_etag:
response = flask.Response(None, status=304)

return response

def index(self, *args, **kwargs): # pylint: disable=unused-argument
scripts = self._generate_scripts_html()
Expand Down