Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Remove service worker

dominik-zeglenfc46a188b0a7
diff --git a/saleor/core/urls.py b/saleor/core/urls.py
index 312861d8ab..52a165708d 100644
--- a/saleor/core/urls.py
+++ b/saleor/core/urls.py
@@ -12,11 +12,6 @@ urlpatterns = [
url(r'^impersonate/stop/$', views.stop_impersonate,
name='impersonate-stop'),
url(r'^404', views.handle_404, name='handle-404'),
- url(r'^offline$', views.offline, name='offline'),
url(r'^manifest\.json$', TemplateView.as_view(
template_name='manifest.json', content_type='application/json')),
- url(r'^serviceworker\.js', TemplateView.as_view(
- template_name="serviceworker.js",
- content_type='application/javascript',
- ), name='serviceworker.js'),
]
diff --git a/saleor/static/js/components/misc.js b/saleor/static/js/components/misc.js
index 7e8530d7cf..1a9495e245 100644
--- a/saleor/static/js/components/misc.js
+++ b/saleor/static/js/components/misc.js
@@ -26,15 +26,4 @@ export default $(document).ready((e) => {
let hash = window.location.hash;
$('.nav-tabs a[href="' + hash + '"]').tab('show');
-
- if ('serviceWorker' in navigator) {
- navigator.serviceWorker
- .register('/serviceworker.js')
- .then((registration) => {
- console.log('Registration successful, scope is:', registration.scope);
- })
- .catch((error) => {
- console.log('Service worker registration failed, error:', error);
- });
- }
});
diff --git a/templates/serviceworker.js b/templates/serviceworker.js
deleted file mode 100644
index 2dfef188a7..0000000000
--- a/templates/serviceworker.js
+++ /dev/null
@@ -1,45 +0,0 @@
-const cacheName = 'staticFiles';
-
-// during the install phase you usually want to cache static assets
-self.addEventListener('install', (e) => {
- // once the SW is installed, go ahead and fetch the resources to make this work offline
- e.waitUntil(
- caches.open(cacheName)
- .then((cache) => {
- return cache.addAll([
- '/',
- '/offline'
- ])
- .then(() => {
- self.skipWaiting();
- })
- .catch(e => console.error(e));
- })
- .catch(e => console.error(e))
- );
-});
-
-// when the browser fetches a url
-self.addEventListener('fetch', (event) => {
- if (event.request.url.match(/http:\/\/.*((\.(css|js|svg)$)|(placeholder\d+x\d+\.png$))/)) {
- console.log(event.request.url);
- caches.open(cacheName)
- .then(cache => cache.add(event.request.url))
- .then(() => self.skipWaiting())
- .catch(e => {
- console.log(event.request.url);
- console.error(e);
- });
- }
- event.respondWith(
- fetch(event.request)
- .catch(() => {
- if (!event.request.url.match(/\.(js|css|eot|otf|png|svg|ttf|woff|woff2)(\?v=[0-9.]+)?$/)) {
- console.log(event.request.url);
- return caches.match('/offline')
- .then(res => res);
- }
- return caches.match(event.request);
- })
- );
-});