You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
jasongrout
changed the title
Better default caching behavior
Opting out of no-cache default behavior
Feb 12, 2021
Or perhaps it's easy for an extension to override this default caching behavior by subclassing a static file handler? If so, it would be great to have an example.
It seems that the
no-cache
cache control header is set by default on files served, unless a request has av=
query parameter:jupyter_server/jupyter_server/base/handlers.py
Lines 719 to 721 in b993b2d
jupyter_server/jupyter_server/base/handlers.py
Lines 661 to 662 in b993b2d
This logic came from this commit in the notebook server, and seems to have been introduced for notebook 4.0:
jupyter/notebook@fe730a6
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?
The text was updated successfully, but these errors were encountered: