-
Notifications
You must be signed in to change notification settings - Fork 380
Description
It seems that the no-cache cache control header is set by default on files served, unless a request has a v= query parameter:
jupyter_server/jupyter_server/base/handlers.py
Lines 719 to 721 in b993b2d
| if "v" not in self.request.arguments or \ | |
| any(self.request.path.startswith(path) for path in self.no_cache_paths): | |
| self.set_header("Cache-Control", "no-cache") |
jupyter_server/jupyter_server/base/handlers.py
Lines 661 to 662 in b993b2d
| if "v" not in self.request.arguments: | |
| self.add_header("Cache-Control", "no-cache") |
This logic came from this commit in the notebook server, and seems to have been introduced for notebook 4.0:
It seems that this logic is trying to make things better by default for static resources that are not cache-friendly (e.g., files that change, but retain the same name). In some ways, it is a workaround for static assets that are not cache-friendly.
In some webapps like JupyterLab, static resources are compiled to be cache friendly. For example, our static files generated from webpack contain a content hash in the filename. However, in order to enable caching of these resources, we have to use a workaround like that introduced in jupyterlab/jupyterlab#9776 to instruct webpack to append a ?v= to each request.
It seems it would be cleaner if we could opt out of the no-cache default behavior at the handler level instead of having to put in extra code to work around it at the individual request level.
Perhaps it's too much to ask for the default to be allowing caching, and those that need a default no-cache behavior at the handler level having to opt in to it?