- From: Jake Archibald <notifications@github.com>
- Date: Sat, 14 Sep 2019 21:25:13 -0700
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Sunday, 15 September 2019 04:25:35 UTC
Thoughts ahead of TPAC: What problems are we looking to solve here? Performance, developer ergonomics, or both? How would https://github.com/w3c/ServiceWorker/issues/1457#issuecomment-521652666 interact with clear-site-data of either origin? Here's some code to compare: # Handling redirects in a service worker ```js addEventListener('fetch', event => { const { request } = event; if (request.mode !== 'navigate') return; const url = new URL(request.url); if (url.pathname === '/cna/') { event.respondWith( Response.redirect('https://example.com/cool-new-app/', 301), ); } }); ``` # With static routing I didn't sketch anything specifically for redirects, but I think it'd look something like this: ```js addEventListener('install', event => { event.router.add( { mode: 'navigate', url: { is: '/cna/', ignoreSearch: true }, }, ['redirect', { url: 'https://example.com/cool-new-app/', status: 301 }], ); }); ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/issues/1457#issuecomment-531533478
Received on Sunday, 15 September 2019 04:25:35 UTC