Skip to content

Commit 7d847c6

Browse files
authored
Merge pull request #309 from plotly/dev-mode-disable-cache
Bust the assets cache on modification.
2 parents cc0599b + 67f8601 commit 7d847c6

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.24.0 - 2018-08-10
2+
## Added
3+
- 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)
4+
15
## 0.23.1 - 2018-08-02
26
## Added
37
- Add ie-compat meta tag to the index by default. [#316](https://github.com/plotly/dash/pull/316)

dash/dash.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ def _relative_url_path(relative_package_path='', namespace=''):
302302
)
303303
elif 'asset_path' in resource:
304304
static_url = flask.url_for('assets.static',
305-
filename=resource['asset_path'])
305+
filename=resource['asset_path'],
306+
mod=resource['ts'])
306307
srcs.append(static_url)
307308
return srcs
308309

@@ -863,8 +864,8 @@ def _walk_assets_directory(self):
863864
walk_dir = self._assets_folder
864865
slash_splitter = re.compile(r'[\\/]+')
865866

866-
def add_resource(p):
867-
res = {'asset_path': p}
867+
def add_resource(p, filepath):
868+
res = {'asset_path': p, 'filepath': filepath}
868869
if self.config.assets_external_path:
869870
res['external_url'] = '{}{}'.format(
870871
self.config.assets_external_path, path)
@@ -887,10 +888,13 @@ def add_resource(p):
887888
else:
888889
path = f
889890

891+
full = os.path.join(current, f)
892+
890893
if f.endswith('js'):
891-
self.scripts.append_script(add_resource(path))
894+
self.scripts.append_script(
895+
add_resource(path, full))
892896
elif f.endswith('css'):
893-
self.css.append_css(add_resource(path))
897+
self.css.append_css(add_resource(path, full))
894898
elif f == 'favicon.ico':
895899
self._favicon = path
896900

dash/resources.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from copy import copy
22
import json
33
import warnings
4+
import os
45

56
from .development.base_component import Component
67

@@ -30,7 +31,9 @@ def _filter_resources(self, all_resources):
3031
elif 'absolute_path' in s:
3132
filtered_resource['absolute_path'] = s['absolute_path']
3233
elif 'asset_path' in s:
34+
info = os.stat(s['filepath'])
3335
filtered_resource['asset_path'] = s['asset_path']
36+
filtered_resource['ts'] = info.st_mtime
3437
elif self.config.serve_locally:
3538
warnings.warn(
3639
'A local version of {} is not available'.format(

dash/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.23.1'
1+
__version__ = '0.24.0'

0 commit comments

Comments
 (0)