1
0
Fork 0
forked from forgejo/forgejo

Enable contenthash in filename for dynamic assets (#20813) (#20932)

This should solve the main problem of dynamic assets getting stale after
a version upgrade. Everything not affected will use query-string based
cache busting, which includes files loaded via HTML or worker scripts.
This commit is contained in:
silverwind 2022-08-25 08:16:20 +02:00 committed by GitHub
parent 5ebd26d306
commit 85f829fb3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 1015 additions and 3038 deletions

View file

@ -1,7 +1,7 @@
import $ from 'jquery';
import prettyMilliseconds from 'pretty-ms';
const {appSubUrl, csrfToken, notificationSettings, enableTimeTracking} = window.config;
const {appSubUrl, csrfToken, notificationSettings, enableTimeTracking, assetVersionEncoded} = window.config;
export function initStopwatch() {
if (!enableTimeTracking) {
@ -41,7 +41,7 @@ export function initStopwatch() {
// if the browser supports EventSource and SharedWorker, use it instead of the periodic poller
if (notificationSettings.EventSourceUpdateTime > 0 && window.EventSource && window.SharedWorker) {
// Try to connect to the event source via the shared worker first
const worker = new SharedWorker(`${__webpack_public_path__}js/eventsource.sharedworker.js`, 'notification-worker');
const worker = new SharedWorker(`${__webpack_public_path__}js/eventsource.sharedworker.js?v=${assetVersionEncoded}`, 'notification-worker');
worker.addEventListener('error', (event) => {
console.error('worker error', event);
});