ipfs/service-worker-gateway

Slow iframe requests to root domain (unintended cache bypass)

lidel opened this issue · 3 comments

Right now, every subdomain load makes additional request to the root domain with custom query parameter, which is effectively bypassing caches (even one from https://github.com/ipshipyard/waterworks-infra/pull/42) and forces rainbow to do work every time again.

This is why we sometimes see /config?origin being stuck in pending state:

2024-03-06_14-46

And then often resulting in 504 for the iframe:

2024-03-06_14-46_1

Solution

We should lean towards maximizing HTTP and browser cache and switch config logic from server-side /path?query to client-side #framents

  • iframe should make request to /#config of the root domain, not /config. This way already cached / response can be returned instead of bypassing caches and rainbow having to produce it again
  • ?origin query param should be replaced with frament param, e.g. /#config@origin=. ?origin will create separate cache entry per origin. /#foo is always better, works without SW being in place, URL hash fragments are not sent to HTTP server, allowing for cache reuse, but can still be read by JS running in iframe

@SgtPooki @2color fyi, this will be blocking the fast SW install and page load on subdomains

Didn't we discuss yesterday that we would be removing the config iframe altogether and just use the SWGW landing page for users to configure?

It seems that we need to load the iframe from the root domain so that we can have global config for all subdomains as per comment from Russell

This should be fixed by #96 and the others linked from it (daniels PR)