ipfs/service-worker-gateway

Subdomain loads require 30MiB download every time

lidel opened this issue · 3 comments

The ./dist without .gz files is ~30MiB.

This means every website that is loaded via subdomain gateway will re-download the same payload before SW can be initialized. This adds 30MiB cost to every website's initial load.

We should reduce the size of subdomain load to minimum to initialize worker. Ideas welcome!

Ideas

  • Perhaps we can reuse already cached verified-fetch assets from the root domain, avoid fetching them again, and only have light sw.js handling registration?
  • ?

another potential reduction in downloaded resources for subdomains: split all required assets for redirect page into a separate chunk, and update app.tsx to use dynamic imports for different pages

do we have agreed-upon action items for this? If my above proposal is appropriate, then actions should be roughly like so:

  • create src/non-subdomain.ts and src/subdomain.ts
  • add the above as entries to webpack
  • make src/app.ts dynamically load the above based on context
  • be sure that src/index.ts is the only file being loaded by webpack, and that it's lightweight (subdomains will load src/index.ts + public/index.html + src/sw.ts)

@lidel thoughts here? should we spend any time working on dynamic loading or are we good as is since resources should be cached from the hosted domain?