meanbee / magento2-serviceworker

Service Worker extension for Magento 2
MIT License
52 stars 27 forks source link

Service worker caches backend #10

Closed tgerulaitis closed 6 years ago

tgerulaitis commented 6 years ago

Since the service worker is registered on the root of the Magento installation, all routes are affected unless they are explictly set to "NetworkOnly" strategy in the configuration. This means that if you visit the frontend first (which registers the service worker) and then navigate to the backend, the service worker stays active and uses the default strategy to serve requests.

While theoretically it would be interesting to speed up the admin area with service worker caching, currently it is a bit of a headache, especially if you start customising the caching strategies and using an app shell. For now, I think we should update the service worker JS to always use "NetworkOnly" strategy for any URL that matches the backend frontname.

davidbrandastic commented 6 years ago

One side-effect of this is the placement of the admin URI into a JS file that is accessible from the front end resulting in that data being potentially leaked to customers.

tgerulaitis commented 6 years ago

Good point, @davidbrandastic. Though I don't know if there's any way to get around that if we want to prevent the service worker from caching the backend.