diff --git a/IPython/html/base/handlers.py b/IPython/html/base/handlers.py index 8765c3dbe..908e18ad4 100644 --- a/IPython/html/base/handlers.py +++ b/IPython/html/base/handlers.py @@ -320,7 +320,7 @@ class AuthenticatedFileHandler(IPythonHandler, web.StaticFileHandler): def set_headers(self): super(AuthenticatedFileHandler, self).set_headers() - # disable browser caching, rely in 304 replies for savings + # disable browser caching, rely on 304 replies for savings if "v" not in self.request.arguments: self.add_header("Cache-Control", "no-cache") @@ -394,11 +394,14 @@ class FileFindHandler(web.StaticFileHandler): def set_headers(self): super(FileFindHandler, self).set_headers() - # disable browser caching, rely in 304 replies for savings - if "v" not in self.request.arguments: + # disable browser caching, rely on 304 replies for savings + if "v" not in self.request.arguments or \ + any(self.request.path.startswith(path) for path in self.no_cache_paths): self.add_header("Cache-Control", "no-cache") - def initialize(self, path, default_filename=None): + def initialize(self, path, default_filename=None, no_cache_paths=None): + self.no_cache_paths = no_cache_paths or [] + if isinstance(path, string_types): path = [path] diff --git a/IPython/html/notebookapp.py b/IPython/html/notebookapp.py index 7e4f48f45..3645cae69 100644 --- a/IPython/html/notebookapp.py +++ b/IPython/html/notebookapp.py @@ -171,6 +171,10 @@ class NotebookWebApplication(web.Application): static_path=ipython_app.static_file_path, static_handler_class = FileFindHandler, static_url_prefix = url_path_join(base_url,'/static/'), + static_handler_args = { + # don't cache custom.js + 'no_cache_paths': [url_path_join(base_url, 'static', 'custom')], + }, version_hash=version_hash, # authentication @@ -218,8 +222,12 @@ class NotebookWebApplication(web.Application): handlers.extend(load_handlers('services.sessions.handlers')) handlers.extend(load_handlers('services.nbconvert.handlers')) handlers.extend(load_handlers('services.kernelspecs.handlers')) + handlers.append( - (r"/nbextensions/(.*)", FileFindHandler, {'path' : settings['nbextensions_path']}), + (r"/nbextensions/(.*)", FileFindHandler, { + 'path': settings['nbextensions_path'], + 'no_cache_paths': ['/'], # don't cache anything in nbextensions + }), ) # register base handlers last handlers.extend(load_handlers('base.handlers'))