Fix caching and add gzip
This commit is contained in:
parent
610fd5a7c3
commit
da2d461941
|
@ -56,8 +56,13 @@ http:
|
||||||
- '127.0.0.1'
|
- '127.0.0.1'
|
||||||
# Use express-minify to minify CSS and Javascript
|
# Use express-minify to minify CSS and Javascript
|
||||||
minify: false
|
minify: false
|
||||||
# Static content cache (in seconds)
|
# Max-Age for caching. Value should be an integer in milliseconds or a string accepted by
|
||||||
cache-ttl: 0
|
# the `ms` module. Set to 0 to disable caching.
|
||||||
|
max-age: '7d'
|
||||||
|
# Set to false to disable gzip compression
|
||||||
|
gzip: true
|
||||||
|
# Customize the threshold byte size for applying gzip
|
||||||
|
gzip-threshold: 1024
|
||||||
|
|
||||||
# HTTPS server details
|
# HTTPS server details
|
||||||
https:
|
https:
|
||||||
|
|
|
@ -41,7 +41,9 @@ var defaults = {
|
||||||
"root-domain": "localhost",
|
"root-domain": "localhost",
|
||||||
"alt-domains": ["127.0.0.1"],
|
"alt-domains": ["127.0.0.1"],
|
||||||
minify: false,
|
minify: false,
|
||||||
"cache-ttl": 0
|
"max-age": "7d",
|
||||||
|
gzip: true,
|
||||||
|
"gzip-threshold": 1024
|
||||||
},
|
},
|
||||||
https: {
|
https: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const VERSION = "3.5.0";
|
const VERSION = "3.6.0";
|
||||||
var singleton = null;
|
var singleton = null;
|
||||||
var Config = require("./config");
|
var Config = require("./config");
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,11 @@ module.exports = {
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
if (Config.get("http.gzip")) {
|
||||||
|
app.use(require("compression")({ threshold: Config.get("http.gzip-threshold") }));
|
||||||
|
Logger.syslog.log("Enabled gzip compression");
|
||||||
|
}
|
||||||
|
|
||||||
if (Config.get("http.minify")) {
|
if (Config.get("http.minify")) {
|
||||||
var cache = path.join(__dirname, "..", "..", "www", "cache")
|
var cache = path.join(__dirname, "..", "..", "www", "cache")
|
||||||
if (!fs.existsSync(cache)) {
|
if (!fs.existsSync(cache)) {
|
||||||
|
@ -237,7 +242,9 @@ module.exports = {
|
||||||
require("./auth").init(app);
|
require("./auth").init(app);
|
||||||
require("./account").init(app);
|
require("./account").init(app);
|
||||||
require("./acp").init(app);
|
require("./acp").init(app);
|
||||||
app.use(static(path.join(__dirname, "..", "..", "www")));
|
app.use(static(path.join(__dirname, "..", "..", "www"), {
|
||||||
|
maxAge: Config.get("http.max-age") || Config.get("http.cache-ttl")
|
||||||
|
}));
|
||||||
app.use(function (err, req, res, next) {
|
app.use(function (err, req, res, next) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.message && err.message.match(/failed to decode param/i)) {
|
if (err.message && err.message.match(/failed to decode param/i)) {
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "3.5.0",
|
"version": "3.6.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bcrypt": "^0.8.0",
|
"bcrypt": "^0.8.0",
|
||||||
"body-parser": "^1.6.5",
|
"body-parser": "^1.6.5",
|
||||||
|
"compression": "^1.2.0",
|
||||||
"cookie-parser": "^1.3.2",
|
"cookie-parser": "^1.3.2",
|
||||||
"express": "^4.8.5",
|
"express": "^4.8.5",
|
||||||
"express-minify": "0.0.11",
|
"express-minify": "0.0.11",
|
||||||
|
|
Loading…
Reference in a new issue