mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
fix for caching plugin-definitions
This commit is contained in:
parent
bdb78adb3f
commit
0bb3e65020
5 changed files with 32 additions and 20 deletions
|
@ -42,20 +42,6 @@ const _ = require('underscore');
|
||||||
exports.root = absolutePaths.findEtherpadRoot();
|
exports.root = absolutePaths.findEtherpadRoot();
|
||||||
console.log(`All relative paths will be interpreted relative to the identified Etherpad base dir: ${exports.root}`);
|
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
|
* The app title, visible e.g. in the browser window
|
||||||
*/
|
*/
|
||||||
|
@ -796,6 +782,20 @@ exports.reloadSettings = () => {
|
||||||
// using Unix socket for connectivity
|
// 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.');
|
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
|
// initially load settings
|
||||||
|
|
|
@ -12,9 +12,10 @@ exports.update = (cb) => {
|
||||||
// of execution on Firefox. This schedules the response in the run-loop,
|
// of execution on Firefox. This schedules the response in the run-loop,
|
||||||
// which appears to fix the issue.
|
// which appears to fix the issue.
|
||||||
const callback = () => setTimeout(cb, 0);
|
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.plugins = data.plugins;
|
||||||
defs.parts = data.parts;
|
defs.parts = data.parts;
|
||||||
defs.hooks = pluginUtils.extractHooks(defs.parts, 'client_hooks');
|
defs.hooks = pluginUtils.extractHooks(defs.parts, 'client_hooks');
|
||||||
|
|
|
@ -5,11 +5,14 @@ const plugins = require('./plugins');
|
||||||
const hooks = require('./hooks');
|
const hooks = require('./hooks');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
const runCmd = require('../../../node/utils/run_cmd');
|
const runCmd = require('../../../node/utils/run_cmd');
|
||||||
|
const settings = require('../../../node/utils/Settings');
|
||||||
|
|
||||||
const logger = log4js.getLogger('plugins');
|
const logger = log4js.getLogger('plugins');
|
||||||
|
|
||||||
const onAllTasksFinished = () => {
|
const onAllTasksFinished = async () => {
|
||||||
hooks.aCallAll('restartServer', {}, () => {});
|
settings.reloadSettings();
|
||||||
|
await hooks.aCallAll('loadSettings', {settings});
|
||||||
|
await hooks.aCallAll('restartServer');
|
||||||
};
|
};
|
||||||
|
|
||||||
let tasks = 0;
|
let tasks = 0;
|
||||||
|
|
|
@ -478,7 +478,11 @@
|
||||||
<!-- Bootstrap page -->
|
<!-- Bootstrap page -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
||||||
var clientVars = {};
|
var clientVars = {
|
||||||
|
// This is needed to fetch /pluginfw/plugin-definitions.json, which happens before the
|
||||||
|
// server sends the CLIENT_VARS message.
|
||||||
|
randomVersionString: <%-JSON.stringify(settings.randomVersionString)%>,
|
||||||
|
};
|
||||||
(function () {
|
(function () {
|
||||||
var pathComponents = location.pathname.split('/');
|
var pathComponents = location.pathname.split('/');
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,11 @@
|
||||||
<!-- Bootstrap -->
|
<!-- Bootstrap -->
|
||||||
<script type="text/javascript" >
|
<script type="text/javascript" >
|
||||||
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt
|
||||||
var clientVars = {};
|
var clientVars = {
|
||||||
|
// This is needed to fetch /pluginfw/plugin-definitions.json, which happens before the
|
||||||
|
// server sends the CLIENT_VARS message.
|
||||||
|
randomVersionString: <%-JSON.stringify(settings.randomVersionString)%>,
|
||||||
|
};
|
||||||
var BroadcastSlider;
|
var BroadcastSlider;
|
||||||
(function () {
|
(function () {
|
||||||
var pathComponents = location.pathname.split('/');
|
var pathComponents = location.pathname.split('/');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue