Skip to content

Commit

Permalink
ADDED - gzip compression of static files + bumped version
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Lesperance committed Mar 11, 2012
1 parent 50eb1b7 commit 44d7090
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
26 changes: 14 additions & 12 deletions lib/client/client.js
@@ -1,15 +1,16 @@
var async = require('async')
, fs = require('fs')
, path = require('path')
, express = require('express')
var async = require('async')
, fs = require('fs')
, path = require('path')
, express = require('express')

, jade = require('jade')
, jade = require('jade')

, child_process = require('child_process')
, events = require('events')
, child_process = require('child_process')
, events = require('events')

, EventEmitter = events.EventEmitter
, EventEmitter = events.EventEmitter

, gzip = require('connect-gzip')
;

var asyncFs = require('../util/async_fs')
Expand All @@ -33,6 +34,7 @@ var asyncFs = require('../util/async_fs')

, JADE_RUNTIME_FILE_NAME = config.JADE_RUNTIME_FILE_NAME

, STATIC_FILES_CACHE_LIFETIME = config.STATIC_FILES_CACHE_LIFETIME
;

/******************************************************************************
Expand Down Expand Up @@ -625,13 +627,13 @@ exports.setup = function setup_client() {
* sets up a static middleware to serve the webapp `client/static` folder
* as `/static`
*/
app.use('/static', express.static(static_dir_path));
app.use('/static', gzip.staticGzip(static_dir_path, { maxAge : STATIC_FILES_CACHE_LIFETIME }));

/***
* sets up a static middleware to serve the rocket `rocket-js` folder
* as `/rocket-js`
*/
app.use('/js/rocket', express.static(path.join(__dirname, 'rocket-js')));
app.use('/js/rocket', gzip.staticGzip(path.join(__dirname, 'rocket-js'), { maxAge : STATIC_FILES_CACHE_LIFETIME }));

if (process.env['NODE_ENV'] === 'production') {

Expand All @@ -644,7 +646,7 @@ exports.setup = function setup_client() {

//sets up a static middleware to serve the webapp optimized tmp js folder
//as `/js`
app.use('/js', express.static(client_js_tmpdir.path));
app.use('/js', gzip.staticGzip(client_js_tmpdir.path, { maxAge : STATIC_FILES_CACHE_LIFETIME }));

callback(null);
}
Expand All @@ -659,7 +661,7 @@ exports.setup = function setup_client() {

//sets up a static middleware to serve the webapp optimized tmp css folder
//as `/css`
app.use('/css', express.static(client_css_tmpdir.path));
app.use('/css', gzip.staticGzip(client_css_tmpdir.path, { maxAge : STATIC_FILES_CACHE_LIFETIME }));

callback(null);

Expand Down
6 changes: 4 additions & 2 deletions lib/config.js
Expand Up @@ -56,7 +56,9 @@ module.exports = new function() {

this.LOCALES_NAME_REGEXP = new RegExp(this.MODULE_NAME_REGEXP);

this.DEVELOPMENT_LISTEN_PORT = 3000
this.PRODUCTION_LISTEN_PORT = 80
this.DEVELOPMENT_LISTEN_PORT = 3000;
this.PRODUCTION_LISTEN_PORT = 80;

this.STATIC_FILES_CACHE_LIFETIME = 365 * 86400000; //one-year

};
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "rocket"
, "description": "The rapid development framework for node.js"
, "keywords": ["mvc", "model view controller", "comet","rapid development", "Rocket", "framework"]
, "version": "0.1.19"
, "version": "0.2.0"
, "homepage": "http://wavo.me"
, "repository":
{ "type" : "git"
Expand All @@ -28,6 +28,7 @@
, "jade-i18n" : "= 0.0.2"
, "now" : ">= 0.7.4"
, "colors" : "0.6.x"
, "connect-gzip" : "0.1.5"
}
, "devDependencies": {
"jessie" : ">= 0.3.7"
Expand Down

0 comments on commit 44d7090

Please sign in to comment.