Skip to content

Commit

Permalink
Merge pull request #2059 from bhollis/cache-service-worker
Browse files Browse the repository at this point in the history
Avoid caching the service worker
  • Loading branch information
bhollis committed Aug 4, 2017
2 parents 0079eb0 + cc9172a commit 6987246
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ module.exports = (env) => {
'return.html',
],
// swSrc: './src/sw.js',
swDest: './dist/sw.js'
swDest: './dist/service-worker.js'
}));
}

Expand Down
12 changes: 12 additions & 0 deletions src/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -958,3 +958,15 @@ FileETag None
</FilesMatch>

</IfModule>

# Do not cache the service worker!

<Files "service-worker.js">
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header unset Expires
</IfModule>
</Files>
4 changes: 3 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
</head>

<body>
<app></app>
<app>
DIM hasn't loaded. Something may be wrong with it, or with your browser (maybe you have a content blocker, or have disabled JavaScript). Try force reloading to make sure (Ctrl-F5 or Cmd-R).
</app>
<div id="browser-warning" class="hidden">Your browser is not supported by DIM. Some or all DIM functionality may not work. Please upgrade to a supported browser.</div>

<script async src="https://www.google-analytics.com/analytics.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require('./app/shell/dimManifestProgress.directive');
require('./scss/main.scss');

if ($DIM_FLAVOR !== 'dev' && navigator.serviceWorker) {
navigator.serviceWorker.register('/sw.js')
navigator.serviceWorker.register('/service-worker.js')
.catch((err) => {
console.error('Unable to register service worker.', err);
});
Expand Down

0 comments on commit 6987246

Please sign in to comment.