From 0bb3e6502065b94647d9fe9662b4a744adabde79 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Mon, 15 Feb 2021 08:52:38 +0100 Subject: [PATCH] fix for caching plugin-definitions --- src/node/utils/Settings.js | 28 ++++++++++++------------ src/static/js/pluginfw/client_plugins.js | 5 +++-- src/static/js/pluginfw/installer.js | 7 ++++-- src/templates/pad.html | 6 ++++- src/templates/timeslider.html | 6 ++++- 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 202e80c60..70e9bb456 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -42,20 +42,6 @@ const _ = require('underscore'); exports.root = absolutePaths.findEtherpadRoot(); console.log(`All relative paths will be interpreted relative to the identified Etherpad base dir: ${exports.root}`); -/* - * At each start, Etherpad generates a random string and appends it as query - * parameter to the URLs of the static assets, in order to force their reload. - * Subsequent requests will be cached, as long as the server is not reloaded. - * - * For the rationale behind this choice, see - * https://github.com/ether/etherpad-lite/pull/3958 - * - * ACHTUNG: this may prevent caching HTTP proxies to work - * TODO: remove the "?v=randomstring" parameter, and replace with hashed filenames instead - */ -exports.randomVersionString = randomString(4); -console.log(`Random string used for versioning assets: ${exports.randomVersionString}`); - /** * The app title, visible e.g. in the browser window */ @@ -796,6 +782,20 @@ exports.reloadSettings = () => { // using Unix socket for connectivity console.warn('The settings file contains an empty string ("") for the "ip" parameter. The "port" parameter will be interpreted as the path to a Unix socket to bind at.'); } + + /* + * At each start, Etherpad generates a random string and appends it as query + * parameter to the URLs of the static assets, in order to force their reload. + * Subsequent requests will be cached, as long as the server is not reloaded. + * + * For the rationale behind this choice, see + * https://github.com/ether/etherpad-lite/pull/3958 + * + * ACHTUNG: this may prevent caching HTTP proxies to work + * TODO: remove the "?v=randomstring" parameter, and replace with hashed filenames instead + */ + exports.randomVersionString = randomString(4); + console.log(`Random string used for versioning assets: ${exports.randomVersionString}`); }; // initially load settings diff --git a/src/static/js/pluginfw/client_plugins.js b/src/static/js/pluginfw/client_plugins.js index 6163241a6..221e786f8 100644 --- a/src/static/js/pluginfw/client_plugins.js +++ b/src/static/js/pluginfw/client_plugins.js @@ -12,9 +12,10 @@ exports.update = (cb) => { // of execution on Firefox. This schedules the response in the run-loop, // which appears to fix the issue. const callback = () => setTimeout(cb, 0); - $.ajaxSetup({cache: false}); - jQuery.getJSON(`${exports.baseURL}pluginfw/plugin-definitions.json`).done((data) => { + jQuery.getJSON( + `${exports.baseURL}pluginfw/plugin-definitions.json?v=${clientVars.randomVersionString}` + ).done((data) => { defs.plugins = data.plugins; defs.parts = data.parts; defs.hooks = pluginUtils.extractHooks(defs.parts, 'client_hooks'); diff --git a/src/static/js/pluginfw/installer.js b/src/static/js/pluginfw/installer.js index 8908dbaaa..104777d3d 100644 --- a/src/static/js/pluginfw/installer.js +++ b/src/static/js/pluginfw/installer.js @@ -5,11 +5,14 @@ const plugins = require('./plugins'); const hooks = require('./hooks'); const request = require('request'); const runCmd = require('../../../node/utils/run_cmd'); +const settings = require('../../../node/utils/Settings'); const logger = log4js.getLogger('plugins'); -const onAllTasksFinished = () => { - hooks.aCallAll('restartServer', {}, () => {}); +const onAllTasksFinished = async () => { + settings.reloadSettings(); + await hooks.aCallAll('loadSettings', {settings}); + await hooks.aCallAll('restartServer'); }; let tasks = 0; diff --git a/src/templates/pad.html b/src/templates/pad.html index 0f96734e6..819abd868 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -478,7 +478,11 @@