qwik icon indicating copy to clipboard operation
qwik copied to clipboard

Option to prefetch all bundles for offline mode

Open adamdbradley opened this issue 3 years ago • 1 comments

Is your feature request related to a problem?

Right now the service worker is just used for prefetching by default. It could also be used to prefetch all bundles for an SPA use case. However, it should be opt-in only since it wouldn't be ideal for all use-cases.

Describe the solution you'd like

Add options to setupServiceWorker({ ... })

Describe alternatives you've considered

none

Additional context

No response

adamdbradley avatar Sep 20 '22 21:09 adamdbradley

Would be awesome to make this also work without serviceworker, cause then we can deploy also in a webview context like capacitorjs and make qwik cross plattform. <3

maxcodefaster avatar May 03 '23 10:05 maxcodefaster

@maxcodefaster actually the SSR adapter already pre-serves all the javascript bundles and Capacitor can use them even offline. The only caveat, is when the user deletes the cache, doing it himself or with a cleaner app, then the app won't work offline anymore.

maiieul avatar May 16 '23 12:05 maiieul

@maxcodefaster actually the SSR adapter already pre-serves all the javascript bundles and Capacitor can use them even offline. The only caveat, is when the user deletes the cache, doing it himself or with a cleaner app, then the app won't work offline anymore.

Thank you for your answer. Afaik you are proposing that the assets should be pulled from the server and then cached in the web view. Problem here is that It is way better to have the assets already on disk rather then needing to pull them from the server. This is cause 1. Assets are available from the start 2. App stores do not officially allow just webview wrappers with basically an iframe. Assets need to be available offline. 3. Service workers do not work on web views.

maxcodefaster avatar May 31 '23 08:05 maxcodefaster

  1. Service workers do not work on web views.

Web views do support service workers. On iOS it requires using App-Bound Domains.

mfulton26 avatar May 31 '23 12:05 mfulton26

  1. Service workers do not work on web views.

Web views do support service workers. On iOS it requires using App-Bound Domains.

Yeah if you serve the page over the wire but I am talking about pre bundled and serving from disk to get it to work with capacitorjs. You can not serve the local files over SSL and therefore not use a service worker. There should be an option to compile qwik front end assets to an spa bundle to make it possible to serve from disk on localhost and without ssl

maxcodefaster avatar Jun 04 '23 12:06 maxcodefaster

I am wondering what @adamdbradley and @manucorporat think about getting qwik to work with capacitorjs as they are former ionic employees.. should be possible for u guys :)

maxcodefaster avatar Jun 13 '23 12:06 maxcodefaster

👋 I am also curious if it's possible to integrate Capacitor and Qwik somehow. The way Capacitor works is by integrating a static HTML version of your app (in Qwik this would have to be generated with the Static Site Adapter). The HTML, CSS and JS files are then packed into your app, and a local http server runs on your iOS or Android device and loads your files. Capacitor is not a web view to your production web server.

Additionally, the Capacitor web view doesn't seem to support a service worker so in order for this to work the JS would have to be eagerly loaded when the page loads.

The use case for this is hybrid apps, where you can share your application code between Capacitor (built with static html export) and Web (built with Node or serverless adapters). I have successfully used this technique in other frameworks like SvelteKit but it doesn't seem possible with Qwik as of now.

khromov avatar Jan 25 '24 17:01 khromov

the JS would have to be eagerly loaded when the page loads.

Can't it load on demand? The Qwik SSG will have created everything and if you don't use any server side features, it should just work?

wmertens avatar Jan 25 '24 19:01 wmertens

don't we have this now with the PWA plugin https://github.com/QwikDev/pwa

PatrickJS avatar Jan 31 '24 06:01 PatrickJS

Closing in favor of the PWA plugin

wmertens avatar Mar 05 '24 09:03 wmertens