0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Cache control for private blogs

no issue

- private blogs need to not be cached, so that the cookie is always checked
This commit is contained in:
Hannah Wolfe 2015-05-18 19:12:42 +01:00
parent 8adc8cb4d8
commit f3174de9e2
2 changed files with 18 additions and 1 deletions

View file

@ -23,7 +23,11 @@ cacheControl = function (options) {
return function cacheControlHeaders(req, res, next) {
if (output) {
res.set({'Cache-Control': output});
if (res.isPrivateBlog) {
res.set({'Cache-Control': profiles['private']});
} else {
res.set({'Cache-Control': output});
}
}
next();
};

View file

@ -77,5 +77,18 @@ describe('Middleware: cacheControl', function () {
});
});
});
it('will override public with private for private blogs', function (done) {
res.isPrivateBlog = true;
middleware.cacheControl('public')(null, res, function (a) {
should.not.exist(a);
res.set.calledOnce.should.be.true;
res.set.calledWith({
'Cache-Control':
'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'
});
done();
});
});
});
});