2
1
Fork 0
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:
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 // Don't set x-cache-invalidate header for drafts
if (hasStatusChanged || wasDeleted || wasPublishedUpdated) { if (hasStatusChanged || wasDeleted || wasPublishedUpdated) {
cacheInvalidate = '/*'; cacheInvalidate = '/*';
} else {
cacheInvalidate = '/' + config.routeKeywords.preview + '/' + post.uuid + '/';
} }
} }
} }

View file

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

View file

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