mirror of
https://github.com/TryGhost/Ghost.git
synced 2023-12-13 21:00:40 +01:00
Cache invalidate for previews
no issue - draft updates now need to affect the preview route
This commit is contained in:
parent
26548a734a
commit
023755c566
3 changed files with 7 additions and 2 deletions
|
@ -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 + '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue