Cache invalidate for previews

no issue

- draft updates now need to affect the preview route
This commit is contained in:
Hannah Wolfe 2015-05-18 20:56:41 +01:00
parent 26548a734a
commit 023755c566
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();
});
});