diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ed3850535..c9aab1c6b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.24.0 - 2018-08-10 +## Added +- Add a modified time query string to the assets included in the index in order to bust the cache. [#319](https://github.com/plotly/dash/pull/309) + ## 0.23.1 - 2018-08-02 ## Added - Add ie-compat meta tag to the index by default. [#316](https://github.com/plotly/dash/pull/316) diff --git a/dash/dash.py b/dash/dash.py index 7e64b7a973..32d6ee1b22 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -302,7 +302,8 @@ def _relative_url_path(relative_package_path='', namespace=''): ) elif 'asset_path' in resource: static_url = flask.url_for('assets.static', - filename=resource['asset_path']) + filename=resource['asset_path'], + mod=resource['ts']) srcs.append(static_url) return srcs @@ -863,8 +864,8 @@ def _walk_assets_directory(self): walk_dir = self._assets_folder slash_splitter = re.compile(r'[\\/]+') - def add_resource(p): - res = {'asset_path': p} + def add_resource(p, filepath): + res = {'asset_path': p, 'filepath': filepath} if self.config.assets_external_path: res['external_url'] = '{}{}'.format( self.config.assets_external_path, path) @@ -887,10 +888,13 @@ def add_resource(p): else: path = f + full = os.path.join(current, f) + if f.endswith('js'): - self.scripts.append_script(add_resource(path)) + self.scripts.append_script( + add_resource(path, full)) elif f.endswith('css'): - self.css.append_css(add_resource(path)) + self.css.append_css(add_resource(path, full)) elif f == 'favicon.ico': self._favicon = path diff --git a/dash/resources.py b/dash/resources.py index 70f37a5389..c594864d64 100644 --- a/dash/resources.py +++ b/dash/resources.py @@ -1,6 +1,7 @@ from copy import copy import json import warnings +import os from .development.base_component import Component @@ -30,7 +31,9 @@ def _filter_resources(self, all_resources): elif 'absolute_path' in s: filtered_resource['absolute_path'] = s['absolute_path'] elif 'asset_path' in s: + info = os.stat(s['filepath']) filtered_resource['asset_path'] = s['asset_path'] + filtered_resource['ts'] = info.st_mtime elif self.config.serve_locally: warnings.warn( 'A local version of {} is not available'.format( diff --git a/dash/version.py b/dash/version.py index db714a8550..f8ab8c2e1f 100644 --- a/dash/version.py +++ b/dash/version.py @@ -1 +1 @@ -__version__ = '0.23.1' +__version__ = '0.24.0'