Skip to content

Commit

Permalink
В конфиг добавлена опция gzip для компрессии
Browse files Browse the repository at this point in the history
  • Loading branch information
klimashkin committed Dec 26, 2013
1 parent 5c5f4a2 commit e492779
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var pkg = JSON.parse(fs.readFileSync(__dirname + '/package.json', 'utf8')),
storePath = path.normalize(conf.storePath || (__dirname + "/../store/")), //Путь к папке хранилища
servePublic = conf.servePublic, //Флаг, что node должен раздавать статику скриптов
serveStore = conf.serveStore, //Флаг, что node должен раздавать статику хранилища
gzip = conf.gzip, //Использовать gzip

logPath = path.normalize(conf.logPath || (__dirname + "/logs")), //Путь к папке логов
manualGarbageCollect = conf.manualGarbageCollect; //Интервал самостоятельного вызова gc. 0 - выключено
Expand Down Expand Up @@ -178,7 +179,9 @@ async.waterfall([

//app.use(express.logger({ immediate: false, format: 'dev' }));
app.disable('x-powered-by'); // Disable default X-Powered-By
app.use(express.compress());
if (gzip) {
app.use(express.compress());
}
app.use(express.favicon(__dirname + pub + 'favicon.ico', { maxAge: ms('1d') }));
if (land === 'dev') {
app.use('/style', require('less-middleware')({src: __dirname + pub + 'style', force: true, once: false, compress: false, debug: false}));
Expand Down Expand Up @@ -308,7 +311,7 @@ async.waterfall([

server.listen(listenport, listenhost, function () {
logger.info('Host for users: [%s]', protocol + '://' + host);
logger.info('Server listening [%s:%s] in %s-mode \n', listenhost ? listenhost : '*', listenport, land.toUpperCase());
logger.info('Server listening [%s:%s] in %s-mode' + (gzip ? ' with gzip' : '') + '\n', listenhost ? listenhost : '*', listenport, land.toUpperCase());
});

}
Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"servePublic": true, /* Tell app.js serve out its public folder (js, css, etc). @Default true */
"serveStore": true, /* Tell app.js serve out store public folder. @Default true */
"subdomains": "", /* Subdomains for serving store path's public folder divided by _. @Default "" */
"gzip": true, /* Compress response data with gzip/deflate. If using nginx before nodejs, recommend to use gzip there and switch off here. @Default true */

"logPath": "", /* Folder for logs. @Default "./logs" */
"manualGarbageCollect": 0, /* Manual invoke garbage collector in millisec.
Expand Down

0 comments on commit e492779

Please sign in to comment.