Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari not caching large Javascript resources #5558

Closed
malmaud opened this issue Oct 31, 2018 · 23 comments
Closed

Safari not caching large Javascript resources #5558

malmaud opened this issue Oct 31, 2018 · 23 comments
Labels
question status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@malmaud
Copy link

malmaud commented Oct 31, 2018

Describe the bug
Desktop Safari is not caching vendors*.js, resulting in ~15 MB downloads every time a remote Jupyter session is navigated to.

To Reproduce

  • Open a Safari window and navigate to jupyter lab.
  • Close the window.
  • Open a new window and navigate to the same lab. Confirm with the safari devtools that no assets are being loaded from the cache.

This isn't a big deal if the server is local, but for a remote server, this means the 14.77 MB "lab/static/vendors~main.c2e649db00cf6963e74a.js" is being re-downloaded every time jupyterlab is navigated to.

Although note that in Safari, if you reload the same frame that is displaying a notebook, then the resources IS cached and loaded from memory. So the problem is that for some reason, the javascript resources aren't being cached to disk that is shared across Safari windows. I've confirmed that Safari is caching to disk resources from other websites, so this is not a general failure of Safari to cache.

Expected behavior

Safari caches static resources, as Chrome does.

Desktop (please complete the following information):

  • OS: 10.14
  • Browser Safari 12.0
  • JupyterLab [e.g. 0.34.2] 0.34.0
@jasongrout
Copy link
Contributor

So Chrome does cache things?

@jasongrout jasongrout added this to the 1.0 milestone Nov 13, 2018
@jasongrout
Copy link
Contributor

(Just to make sure: you're sure that you have caching enabled when dev tools is open in Safari?)

@jasongrout
Copy link
Contributor

I just checked, and it works for me. I have to make sure the cache is enabled, though:
screen shot 2018-11-12 at 5 13 09 pm

(enable the cache by clicking on the second-to-last icon on the far right, that looks like a cylinder with a line through it, until it is not blue, and the tooltip reads "Ignore the resource cache when loading files")

@jasongrout jasongrout modified the milestones: 1.0, Reference Nov 13, 2018
@malmaud
Copy link
Author

malmaud commented Nov 13, 2018 via email

@malmaud
Copy link
Author

malmaud commented Nov 13, 2018

And ya, chrome devtools confirms that chrome is caching the javascript bundles, even if you close the Chrome frame and open a new one.

@charliwar
Copy link

charliwar commented Jun 4, 2019

I think that the problem its not the caching. The problem its de large javascript file. The navigator cut the petition sometimes and when you try reload if you are lucky the jupyter works.

@flixr
Copy link

flixr commented Jul 31, 2019

I'm having the same problem with JupyterLab 1.0 and Firefox.
My vendors~main.xxxx.js is ~100MB and it is never cached.
In the response headers I can see that Cache-Control is set to no-cache. Same for main.xxxxx.js

@juliusvonkohout
Copy link

juliusvonkohout commented Aug 1, 2019

@jasongrout I can confirm that it is not cached in firefox, but in chrome for jupyterlab 1.0.4
grafik

@jasongrout
Copy link
Contributor

The js is cached for me in Firefox 68

conda create -n del-jlab5558 jupyterlab
conda activate del-jlab5558
conda list | grep jupyterlab

gives

jupyterlab                1.0.4                    py37_0    conda-forge
jupyterlab_server         1.0.0                      py_1    conda-forge

Screen Shot 2019-08-01 at 1 08 15 PM

@jasongrout
Copy link
Contributor

I notice your vendors js file hash is different than mine. Is it a fresh install of jlab 1.0.4 with no extensions?

@jasongrout
Copy link
Contributor

Better screenshot, showing the cache-control header and the 304 not modified response:
Screen Shot 2019-08-01 at 1 11 38 PM

@jasongrout
Copy link
Contributor

Note that no-cache is the expected value of that cache control header. See the difference between no-cache and no-store at https://www.cloudflare.com/learning/cdn/glossary/what-is-cache-control/

Essentially, no-cache is asking the browser to check to see if it has the most recent file before using the cache.

@juliusvonkohout
Copy link

juliusvonkohout commented Aug 1, 2019

Note that no-cache is the expected value of that cache control header. See the difference between no-cache and no-store at https://www.cloudflare.com/learning/cdn/glossary/what-is-cache-control/

Essentially, no-cache is asking the browser to check to see if it has the most recent file before using the cache.

Thanks for the explanation. i have found the problem. the deprecated plotly extension https://github.com/jupyterlab/jupyter-renderers/tree/master/packages/plotly-extension prevents caching and adds almost 20 Megabyte.

I uninstalled it and caching is working.

I installed plotly-jupyterlab and the caching is again not working and the javascript bundle is increased by 20 Megabytes.

At the moment i only have the following extensions installed

jupyterlab-plotly

if i just have @jupyter-widgets/jupyterlab-manager caching works, so there might be something wrong with the official plotly extension

@juliusvonkohout
Copy link

juliusvonkohout commented Aug 2, 2019

@jasongrout @flixr i have solved the problem. It is just firefox caching settings. By default it does not cache files over 51200 KB or 51,2 Megabyte! I changed it to 128 MB and now everything is working fine. I am also trying --dev-build=False since it seems to significantly slim down javascript.
grafik

@flixr
Copy link

flixr commented Aug 2, 2019

@juliusvonkohout 👍 that was it

@charliwar
Copy link

i think that it's not a good solution.

In a platform with hundred users ..... all user must be configure the navigator?

@juliusvonkohout
Copy link

@flixr @jasongrout the solution is to use --dev-build=False everytime you install something. the javascript went down from 55 to 8 Megabyte. The developers should make this default...

@jasongrout
Copy link
Contributor

the solution is to use --dev-build=False everytime you install something

Fixing this I think is #6907 - just merged into master.

@jasongrout
Copy link
Contributor

i have solved the problem. It is just firefox caching settings. By default it does not cache files over 51200 KB or 51,2 Megabyte!

Thanks, that explains why it was different for me, as I was using stock JLab without extensions.

@jasongrout
Copy link
Contributor

Can people here try the new alpha just released on pypi (not available on conda-forge):

pip install --pre --upgrade jupyterlab

This includes some recent changes to build a smaller js bundle by default.

@madsi1m
Copy link

madsi1m commented Aug 23, 2019

Awesome work by the way, really like the lab UX.

Any way to reduce the size of the vendors-main with some kind of minify?
Mine is about 79mb which is very big for ADSL users

@blink1073 blink1073 removed this from the 1.1 milestone Aug 27, 2019
@blink1073 blink1073 added this to the 1.2 milestone Aug 27, 2019
@jasongrout
Copy link
Contributor

FYI, minification is turned on by default in the latest release of jlab.

@jasongrout jasongrout modified the milestones: 1.2, 2.0 Oct 11, 2019
@jasongrout
Copy link
Contributor

Closing as resolved. Please post a comment if this is still an issue.

@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Jan 1, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

No branches or pull requests

8 participants