Make cache max-age on theme assets one year.

closes #2790
- Added one year in ms var.
- refs: #2447
This commit is contained in:
Steve 2014-05-21 20:56:25 -07:00 committed by Steve
parent c7bbb9e789
commit 5f7182b7a2
2 changed files with 6 additions and 5 deletions

View File

@ -10,7 +10,8 @@ var _ = require('lodash'),
api = require('../api'),
expressServer,
ONE_HOUR_MS = 60 * 60 * 1000;
ONE_HOUR_MS = 60 * 60 * 1000,
ONE_YEAR_MS = 365 * 24 * ONE_HOUR_MS;
function isBlackListedFileType(file) {
var blackListedFileTypes = ['.hbs', '.md', '.json'],
@ -172,8 +173,8 @@ var middleware = {
forwardToExpressStatic: function (req, res, next) {
api.settings.read({context: {internal: true}, key: 'activeTheme'}).then(function (response) {
var activeTheme = response.settings[0];
// For some reason send divides the max age number by 1000
express['static'](path.join(config().paths.themePath, activeTheme.value), {maxAge: ONE_HOUR_MS})(req, res, next);
express['static'](path.join(config().paths.themePath, activeTheme.value), {maxAge: ONE_YEAR_MS})(req, res, next);
});
},
@ -191,4 +192,4 @@ var middleware = {
};
module.exports = middleware;
module.exports.cacheServer = cacheServer;
module.exports.cacheServer = cacheServer;

View File

@ -401,7 +401,7 @@ describe('Frontend Routing', function () {
it('should retrieve theme assets', function (done) {
request.get('/assets/css/screen.css')
.expect('Cache-Control', cacheRules.hour)
.expect('Cache-Control', cacheRules.year)
.expect(200)
.end(doEnd(done));
});