Static content caching

This commit is contained in:
Sahat Yalkabov
2014-01-28 01:45:45 -05:00
parent 0a0cc7493b
commit 639db23067
2 changed files with 8 additions and 8 deletions

4
app.js
View File

@@ -41,7 +41,7 @@ var app = express();
/**
* Express configuration.
*/
app.locals.cacheBuster = Date.now();
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
@@ -63,7 +63,7 @@ app.use(function(req, res, next) {
app.use(flash());
app.use(less({ src: __dirname + '/public', compress: true }));
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static( path.join(__dirname, 'public'), { maxAge: 864000000 } ));
app.use(function(req, res) {
res.status(404);
res.render('404');

View File

@@ -9,14 +9,14 @@ html
title #{title} - Starter Template for Bootstrap
link(href='/css/lib/font-awesome.min.css', rel='stylesheet')
link(href='/css/lib/animate.css', rel='stylesheet')
link(href='/css/lib/font-awesome.min.css?v=#{cacheBuster}', rel='stylesheet')
link(href='/css/lib/animate.css?v=#{cacheBuster}', rel='stylesheet')
link(href='/css/styles.css', rel='stylesheet')
link(href='/css/styles.css?v=#{cacheBuster}', rel='stylesheet')
script(src='/js/lib/jquery.js')
script(src='/js/lib/bootstrap.js')
script(src='/js/main.js')
script(src='/js/lib/jquery.js?v=#{cacheBuster}')
script(src='/js/lib/bootstrap.js?v=#{cacheBuster}')
script(src='/js/main.js?v=#{cacheBuster}')
body
#wrap
.navbar.navbar-default.navbar-fixed-top