mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05: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
|
// 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 + '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue