The new 0.14 releases is awesome and an absolute game changer when we want to build python app/dashboards that we want to share with people that might not have python installed.
I was just playing around with building such an app and making it into a PWA. When installing the PWA it would be great if one could load the cache version of pyodide and the python env to reduce the boot time. I can not figure out how to do this - can anybody help me or point in the direction where I could find more information about this?
So by default it’ll cache pyodide and all wheels the first time the app is loaded. I chose this behavior instead of explicitly pre-caching it because if you add it to the pre-cache the app won’t render anything until the pre-caching is complete.
It is a really cool feature that the app is pre rendered and having the load wheel running while pyodide and the rest of the python env is loaded. That it is loading these every time for a website makes sense - but for a PWA it would be really cool if the python run-time env would not need to be downloaded every time the app is opened. I guess it should be possible to make it load the already cached version - but I can not figure out how that would be possible?!
I guess I would need to change something in the service-worker JS script but I can not seem to find the right think to google to find such a solution. Any help or pointers would be much appreciated.
That is exactly what it does when you enable the PWA option. Are you sure you’re seeing the pyodide runtime being downloaded each time? Even when it’s cached it will take at least 5-10 seconds to start up and will go through the steps of Loading Pyodide and loading the other packages. That does not mean it’s redownloading them.
Sorry - you are absolutely right, it is not downloading pyodide every time. The “loading pyodide” is only there for a fraction of a second. I just looked in the console where it says
but I guess that is just from when the pwa was installed. Refreshing the app it is not there.
I guess I hope the boot time of the app would have been faster once pyodide did not need to be downloaded. Would it be possible to cache the python env so it would not need to install the python dependencies every time?
We can explore something like pyodide-pack at some point but it was a little too experimental for my liking. Tons of smart people are thinking about these problems so hopefully we’ll see significant improvements on this front.