Fix caching and add gzip

This commit is contained in:
calzoneman 2014-11-16 21:06:10 -06:00
parent 610fd5a7c3
commit da2d461941
5 changed files with 22 additions and 7 deletions

View file

@ -211,13 +211,18 @@ module.exports = {
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(morgan(LOG_FORMAT, {
stream: require("fs").createWriteStream(path.join(__dirname, "..", "..",
stream: require("fs").createWriteStream(path.join(__dirname, "..", "..",
"http.log"), {
flags: "a",
encoding: "utf-8"
})
}));
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")) {
var cache = path.join(__dirname, "..", "..", "www", "cache")
if (!fs.existsSync(cache)) {
@ -237,7 +242,9 @@ module.exports = {
require("./auth").init(app);
require("./account").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) {
if (err) {
if (err.message && err.message.match(/failed to decode param/i)) {