From dfbc1b3791aec930a858fdaf0e96a937d61771ea Mon Sep 17 00:00:00 2001 From: rhymes Date: Thu, 20 Feb 2020 23:39:17 +0100 Subject: [PATCH] Disable service worker on social previews (#6209) [deploy] --- app/views/service_worker/index.js.erb | 32 +++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/app/views/service_worker/index.js.erb b/app/views/service_worker/index.js.erb index ae4b1500b..895075798 100644 --- a/app/views/service_worker/index.js.erb +++ b/app/views/service_worker/index.js.erb @@ -89,24 +89,28 @@ if (event.clientId === "" && // Not fetched via AJAX after page load. event.request.method == "GET" && // Don't fetch on POST, DELETE, etc. !event.request.referrer.includes('/signout_confirm') && // If this is the referrer, we instead want to flush. + !url.href.includes('i=i') && // Parameter representing "internal" navigation. - !url.href.includes('?signin') && // Don't run on sign in. - !url.href.includes('.js') && // Don't run on JS. !url.href.includes('.css') && // Don't run on CSS. - !url.href.includes('/onboarding') && // Don't run on onboarding. - !url.href.includes('/api/') && // Don't run on API endpoints. - !url.href.includes('/users/auth') && // Don't run on authentication. - !url.href.includes('/shell_') && // Don't fetch for shell. - !url.href.includes('/embed/') && // Don't fetch for embeded content. - !url.href.includes('/admin') && // Don't fetch for administrate dashboard. - !url.href.includes('/internal') && // Don't fetch for internal dashboard. - !url.href.includes('/future') && // Skip for /future. + !url.href.includes('.js') && // Don't run on JS. !url.href.includes('?preview=') && // Skip for preview pages. - !url.href.includes('/sidekiq') && // Skip for Sidekiq dashboard - !url.href.includes('/oauth/') && // Skip oauth apps - !url.href.includes('/robots.txt') && // Skip robots for web crawlers - !url.href.includes('/rails/mailers') && // Skip for mailers previews in development mode + !url.href.includes('?signin') && // Don't run on sign in. + + !url.href.includes('/admin') && // Don't fetch for administrate dashboard. + !url.href.includes('/api/') && // Don't run on API endpoints. + !url.href.includes('/embed/') && // Don't fetch for embeded content. !url.href.includes('/feed') && // Skip the RSS feed + !url.href.includes('/future') && // Skip for /future. + !url.href.includes('/internal') && // Don't fetch for internal dashboard. + !url.href.includes('/oauth/') && // Skip oauth apps + !url.href.includes('/onboarding') && // Don't run on onboarding. + !url.href.includes('/rails/mailers') && // Skip for mailers previews in development mode + !url.href.includes('/robots.txt') && // Skip robots for web crawlers + !url.href.includes('/shell_') && // Don't fetch for shell. + !url.href.includes('/sidekiq') && // Skip for Sidekiq dashboard + !url.href.includes('/social_previews') && // Skip for social previews + !url.href.includes('/users/auth') && // Don't run on authentication. + caches.match('/shell_top') && // Ensure shell_top is in the cache. caches.match('/shell_bottom')) { // Ensure shell_bottom is in the cache. event.respondWith(createPageStream(event.request)); // Respond with the stream