Skip to content

Node.js based forum software built for the modern web

feat: #8801, disable express compression by default

Barış Soner Uşaklı6ac73ccb7e08
diff --git a/install/data/defaults.json b/install/data/defaults.json
index ec5137ac49..18dd27f612 100644
--- a/install/data/defaults.json
+++ b/install/data/defaults.json
@@ -134,5 +134,6 @@
"necroThreshold": 7,
"categoryWatchState": "watching",
"submitPluginUsage": 1,
- "maxUserSessions": 10
+ "maxUserSessions": 10,
+ "useCompression": 0
}
\ No newline at end of file
diff --git a/public/language/en-GB/admin/settings/advanced.json b/public/language/en-GB/admin/settings/advanced.json
index a08f863af1..ce0782be9e 100644
--- a/public/language/en-GB/admin/settings/advanced.json
+++ b/public/language/en-GB/admin/settings/advanced.json
@@ -36,5 +36,8 @@
"analytics.settings": "Analytics Settings",
"analytics.max-cache": "Analytics Cache Max Value",
- "analytics.max-cache-help": "On high-traffic installs, the cache could be exhausted continuously if there are more concurrent active users than the Max Cache value. (Restart required)"
+ "analytics.max-cache-help": "On high-traffic installs, the cache could be exhausted continuously if there are more concurrent active users than the Max Cache value. (Restart required)",
+ "compression.settings": "Compression Settings",
+ "compression.enable": "Enable Compression",
+ "compression.help": "This setting enables gzip compression. For a high-traffic website in production, the best way to put compression in place is to implement it at a reverse proxy level. You can enable it here for testing purposes."
}
\ No newline at end of file
diff --git a/src/views/admin/settings/advanced.tpl b/src/views/admin/settings/advanced.tpl
index cf1934dfc9..eec61df531 100644
--- a/src/views/admin/settings/advanced.tpl
+++ b/src/views/admin/settings/advanced.tpl
@@ -165,4 +165,23 @@
</div>
</div>
+<div class="row">
+ <div class="col-sm-2 col-xs-12 settings-header">[[admin/settings/advanced:compression.settings]]</div>
+ <div class="col-sm-10 col-xs-12">
+ <form>
+ <div class="form-group">
+ <p class="help-block">
+ [[admin/settings/advanced:compression.help]]
+ </p>
+ <div class="checkbox">
+ <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
+ <input class="mdl-switch__input" type="checkbox" data-field="useCompression">
+ <span class="mdl-switch__label"><strong>[[admin/settings/advanced:compression.enable]]</strong></span>
+ </label>
+ </div>
+ </div>
+ </form>
+ </div>
+</div>
+
<!-- IMPORT admin/partials/settings/footer.tpl -->
diff --git a/src/webserver.js b/src/webserver.js
index bf347b1d38..87f5cf654d 100644
--- a/src/webserver.js
+++ b/src/webserver.js
@@ -13,7 +13,6 @@ var server;
var winston = require('winston');
var async = require('async');
var flash = require('connect-flash');
-var compression = require('compression');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var session = require('express-session');
@@ -134,7 +133,10 @@ function setupExpressApp(app) {
app.enable('minification');
}
- app.use(compression());
+ if (meta.config.useCompression) {
+ const compression = require('compression');
+ app.use(compression());
+ }
app.get(relativePath + '/ping', pingController.ping);
app.get(relativePath + '/sping', pingController.ping);