0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Merge pull request #5292 from ErisDS/preview-cache-invalidate

Cache invalidate for previews
This commit is contained in:
Sebastian Gierlinger 2015-05-20 09:31:28 +02:00
commit c6176e4d38
3 changed files with 7 additions and 2 deletions

View file

@ -80,6 +80,8 @@ cacheInvalidationHeader = function (req, result) {
// Don't set x-cache-invalidate header for drafts
if (hasStatusChanged || wasDeleted || wasPublishedUpdated) {
cacheInvalidate = '/*';
} else {
cacheInvalidate = '/' + config.routeKeywords.preview + '/' + post.uuid + '/';
}
}
}

View file

@ -301,8 +301,11 @@ setupMiddleware = function (blogAppInstance, adminApp) {
blogApp.use(passport.initialize());
// ### Caching
// Blog frontend is cacheable
blogApp.use(middleware.cacheControl('public'));
// Admin shouldn't be cached
adminApp.use(middleware.cacheControl('private'));
// API shouldn't be cached
blogApp.use(routes.apiBaseUri, middleware.cacheControl('private'));
// enable authentication

View file

@ -540,8 +540,8 @@ describe('Post API', function () {
return done(err);
}
// Updating a draft should not send x-cache-invalidate headers
should.not.exist(res.headers['x-cache-invalidate']);
// Updating a draft should send x-cache-invalidate headers for the preview only
res.headers['x-cache-invalidate'].should.eql('/p/' + draftPost.posts[0].uuid + '/');
done();
});
});