move serivce worker to base.html
This commit is contained in:
parent
26ef5b082a
commit
4305ea61ba
@ -1,3 +1,35 @@
|
||||
const CACHE_NAME = 'ktvmanager-cache-v1';
|
||||
const urlsToCache = [
|
||||
'/',
|
||||
'/static/styles.css',
|
||||
'/static/favicon.ico',
|
||||
'/static/favicon-96x96.png',
|
||||
'/static/favicon.svg',
|
||||
'/static/apple-touch-icon.png',
|
||||
'/static/web-app-manifest-192x192.png',
|
||||
'/static/web-app-manifest-512x512.png',
|
||||
'/static/site.webmanifest'
|
||||
];
|
||||
|
||||
self.addEventListener('install', function(event) {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME)
|
||||
.then(function(cache) {
|
||||
console.log('Opened cache');
|
||||
return cache.addAll(urlsToCache);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', function(event) {
|
||||
// empty
|
||||
event.respondWith(
|
||||
caches.match(event.request)
|
||||
.then(function(response) {
|
||||
if (response) {
|
||||
return response;
|
||||
}
|
||||
return fetch(event.request);
|
||||
}
|
||||
)
|
||||
);
|
||||
});
|
@ -53,5 +53,10 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
|
||||
{% block scripts %}{% endblock %}
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('{{ url_for("static", filename="service-worker.js") }}')
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -53,9 +53,4 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
navigator.serviceWorker.register('{{ url_for("static", filename="service-worker.js") }}')
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user