Skip to content

Commit

Permalink
Fixed previews not reflecting changes to scheduled posts on Ghost(Pro) (
Browse files Browse the repository at this point in the history
TryGhost#10601)

closes TryGhost#10600
- modifies conditions for when to send a cache invalidation header for preview URLs to include changes to scheduled posts
  • Loading branch information
kevinansfield committed Mar 12, 2019
1 parent 458a57b commit 507d8b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions core/server/api/v2/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,15 @@ module.exports = {
query(frame) {
return models.Post.edit(frame.data.pages[0], frame.options)
.then((model) => {
if (model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published') {
if (
model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published'
) {
this.headers.cacheInvalidate = true;
} else if (model.get('status') === 'draft' && model.previous('status') !== 'published') {
} else if (
model.get('status') === 'draft' && model.previous('status') !== 'published' ||
model.get('status') === 'scheduled' && model.wasChanged()
) {
this.headers.cacheInvalidate = {
value: urlService.utils.urlFor({
relativeUrl: urlService.utils.urlJoin('/p', model.get('uuid'), '/')
Expand Down
11 changes: 8 additions & 3 deletions core/server/api/v2/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,15 @@ module.exports = {
query(frame) {
return models.Post.edit(frame.data.posts[0], frame.options)
.then((model) => {
if (model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published') {
if (
model.get('status') === 'published' && model.wasChanged() ||
model.get('status') === 'draft' && model.previous('status') === 'published'
) {
this.headers.cacheInvalidate = true;
} else if (model.get('status') === 'draft' && model.previous('status') !== 'published') {
} else if (
model.get('status') === 'draft' && model.previous('status') !== 'published' ||
model.get('status') === 'scheduled' && model.wasChanged()
) {
this.headers.cacheInvalidate = {
value: urlService.utils.urlFor({
relativeUrl: urlService.utils.urlJoin('/p', model.get('uuid'), '/')
Expand Down

0 comments on commit 507d8b3

Please sign in to comment.