mirror of
https://github.com/discourse/discourse.git
synced 2025-02-12 14:24:54 +00:00
Merge pull request #5825 from featheredtoast/extend-service-worker-cache
FIX: update cache times for service workers
This commit is contained in:
commit
569f63b8a2
@ -37,6 +37,8 @@ self.addEventListener('install', function(event) {
|
|||||||
return caches.open(CURRENT_CACHES.offline).then(function(cache) {
|
return caches.open(CURRENT_CACHES.offline).then(function(cache) {
|
||||||
return cache.put(OFFLINE_URL, response);
|
return cache.put(OFFLINE_URL, response);
|
||||||
});
|
});
|
||||||
|
}).then(function(cache) {
|
||||||
|
self.skipWaiting();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -60,6 +62,8 @@ self.addEventListener('activate', function(event) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}).then(function() {
|
||||||
|
self.clients.claim()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -160,8 +160,11 @@ class StaticController < ApplicationController
|
|||||||
format.js do
|
format.js do
|
||||||
# https://github.com/w3c/ServiceWorker/blob/master/explainer.md#updating-a-service-worker
|
# https://github.com/w3c/ServiceWorker/blob/master/explainer.md#updating-a-service-worker
|
||||||
# Maximum cache that the service worker will respect is 24 hours.
|
# Maximum cache that the service worker will respect is 24 hours.
|
||||||
immutable_for 24.hours
|
# However, ensure that these may be cached and served for longer on servers.
|
||||||
|
immutable_for 1.year
|
||||||
|
|
||||||
|
path = File.expand_path(Rails.root + "public/assets/#{Rails.application.assets_manifest.assets['service-worker.js']}")
|
||||||
|
response.headers["Last-Modified"] = File.ctime(path).httpdate
|
||||||
render(
|
render(
|
||||||
plain: Rails.application.assets_manifest.find_sources('service-worker.js').first,
|
plain: Rails.application.assets_manifest.find_sources('service-worker.js').first,
|
||||||
content_type: 'application/javascript'
|
content_type: 'application/javascript'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user