When you "Save as draft" a node thanks to the http://drupal.org/project/save_draft module (but I assume this would be the same with any workflow/moderation tool), regular purges are being made as if it was a public facing (Varnish cached) node while it's not.

We're wasting cache purges by unnecessary submitting Varnish cache clears depending upon the workflow state of the node. When it's saved as draft, pending moderation/review, or whatever different from the published state, we should silent the purges.

Comments

nielsvm’s picture

Status: Active » Closed (won't fix)

That's a valid concern yet a less easy fix, or better put, at a different layer. Once the Acquia Purge module is told - by expire.module or customer code - to purge a certain path it will do its utter best to purge that individual path as good as possible and in all potentially existing forms. So if node/1 had to be purged it might issue 1 or even 10 purges depending on the amount of domains.

Yet that's not the issue here. The event has already been submitted by the expire module and we simply adhere and do what it asks. Technically the expire module listens on node_save() events and has probably no integration or understanding about the save_draft module. Therefore the only fix for this is a integration with that module in expire, for instance using a conditional if (module_exists('save_draft')) check to not purge when that module is into play saving a non public node.

I'm forced to close this as won't fix :(, yet I advise to file a ticket at the save_draft or expire project and to link to this comment.

anavarre’s picture

Project: Acquia Purge » Cache Expiration
Version: » 7.x-2.x-dev
Status: Closed (won't fix) » Active

Re-opening but changing project. Please read #1 for implementation ideas.

spleshka’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev

Change branch version. 7.x-2.x has a lot of difference from 7.x-1.x.

spleshka’s picture

Status: Active » Fixed

In 7.x-2.x branch you may configure your own expiration rules using Rules + Cache expiration modules.

spleshka’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Forgot to change version number.

nielsvm’s picture

Status: Fixed » Active

My apologies for reopening this, although I believe with valid reasons. We can't expect site users to be working around this with a rule every time they would install the save_draft module, hence that won't even work as we don't want expire events to go out at all instead of influencing them with a rule.

The scope of this issue is:
Don't include node/X in hook_expire_cache() events once a user uses the "Save as draft" button when they have the save_draft module enabled!

There's a couple of ways forward IMHO.

  1. Implement this in expire with a if(module_exists('save_draft')) {...} kind of exception.
  2. Provide something like a hook_expire_cache_alter() call so the save_draft module can prevent the "drafted" node from being purged.
  3. Let users accept purges to happen while the content didn't actually change at all (which is what save_draft does after node_save() is invoked). :(
spleshka’s picture

I like a second way. Moreover, hook_expire_cache_alter() is already exists, and save_draft module may implement it to remove node/[nid] path from being expired.

nielsvm’s picture

Project: Cache Expiration » Save Draft
Version: 7.x-2.x-dev » 7.x-1.x-dev
Category: feature » bug

My apologies @Spleshka for not checking the existence of hook_expire_cache_alter() myself! That essentially moves the responsibility of implementing this to the save_draft module, can you guys look into this issue?

Thanks!

spleshka’s picture

Status: Active » Needs review
StatusFileSize
new908 bytes

Patch attached.

spleshka’s picture

Category: bug » feature

Suppose this is a feature request, not a bug.

spleshka’s picture

Could anyone review this patch please?

anavarre’s picture

Status: Needs review » Needs work

Patch didn't apply cleanly for me both with patch -p1 in the module directory or with cURL. Did you make it against 7.x-1.4?

spleshka’s picture

Status: Needs work » Needs review

No, patch should be applied to 7.x-1.x. Download project using Git:

git clone --branch 7.x-1.x http://git.drupal.org/project/save_draft.git
cd save_draft

Then apply patch in #9:

git apply -v save_draft-prevent-cache-purges-depending-on-publishing-workflow-states-1887350-9.patch
anavarre’s picture

Sorry I took ages to get back to this but I've tested the patch (successfully applied against 7.x-1.x) with Acquia Purge and I'm still getting the purges.

Is this working ok for you with both Purge and Acquia Purge or only Purge?

spleshka’s picture

I've tested this only for Purge module. Please ensure that you are using Cache Expiration 7.x-2.x branch.

nielsvm’s picture

I'm less concerned about whether it works on Acquia Purge or not, if it works properly on Purge it will do so on Acquia Purge too. If expire now doesn't emit the purging signals during these workflow states we're fine.

Thanks a tonne!

rooby’s picture

Issue summary: View changes
StatusFileSize
new770 bytes

Thanks for the patch. As previously mentioned, if it works with purge it should work the same with Acquia purge.

The problem seems to be that the variable_get() call was not giving a default value, so if you haven't specifically saved the draft settings of your node type this would not have worked.

Here is a new version of the patch that addresses this.

Works for me but can someone confirm before I commit?

rooby’s picture

Priority: Minor » Normal
anavarre’s picture

Not sure if I've tested things correctly here but with the latest Acquia Purge and Save as Draft dev releases + the patch in #17 applied, I still get purges when saving a node as draft.