mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Make cache max-age on theme assets one year.
closes #2790 - Added one year in ms var. - refs: #2447
This commit is contained in:
parent
c7bbb9e789
commit
5f7182b7a2
@ -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;
|
||||
|
@ -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));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user