Problem/Motivation
There are situations when content editor needs a way to flush external cache manually.
Let's assume the editor is in situation when:
- No access to drush or purge_drush not installed
- Not possible to run cron or wait the queue is processed by other methods
- PurgeBlock isn't not configured
- Other cases...
Proposed resolution
The solution is to have a special button on the purgers setting page (admin/config/development/performance/purge), let's call it "Invalidate". The button will allow flushing the cache for a given purger directly using selected invalidate type and its expression(s).
Remaining tasks
Make it possible to flush only selected purger.
User interface changes
New button added for every registered purger on the admin/config/development/performance/purge page.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | interpatch-11-12.txt | 707 bytes | fengtan |
| #13 | purge-2853613-12.patch | 16.06 KB | fengtan |
| #3 | purge-2853613-screenshot-2.png | 82.13 KB | vitalym |
| #3 | purge-2853613-screenshot-1.png | 52.24 KB | vitalym |
Issue fork purge-2853613
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
vitalym commentedHere is a patch that solves this issue. It works almost the same way drush p-invalidate or PurgeBlock do.
Comment #3
vitalym commentedAdding screenshots for better vision.
Comment #4
vitalym commentedComment #5
firewaller commentedThis works well for me in my initial tests. I'll do some more testing on my live CloudFront to confirm.
@VitalyM unrelated, but is there a way to submit this form programmatically?
Comment #6
vitalym commented@firewaller If you take a look at code around the line
in the patch, you may build your own code to invalidate automatically w/o a form.
Comment #7
firewaller commented@VitalyM thanks! I figured it out.
Comment #8
eleonelHi, I created a module to invalidate items immediately using a form: https://www.drupal.org/project/purge_invalidation_form
I hope this helps anyone looking for this functionality.
Comment #9
joseph.olstadhi eleonel, thanks for sharing your module
I previously created varnishvanish for the same purpose
I'm not sure which is better, your module, or the one I created
https://www.drupal.org/project/varnishvanish
I haven't tested varnishvanish on D9 yet.
Comment #10
fengtanPatch #2 works fine on our side. Thanks!
There is one limitation though: the form shows no success or error message when submitted.
This is because the patch is using
drupal_set_message()which is now deprecated https://www.drupal.org/node/2774931Attached is a new patch that replaces drupal_set_message() with \Drupal\Core\Messenger\MessengerInterface::addMessage() as recommended by the change record above.
Comment #12
fengtanSomehow the bot says a test about conditional access is failing. The changeset added in #10 only addresses a messenger deprecation so it is not clear how this is related.
Here is an attempt to resolve this,
let's see what the bot says...tests are green now!Comment #13
fengtanPatch does not apply anymore against 8.x-3.x -- re-rolled
Comment #14
baluertlComment #15
junkunczpurge-2853613-12.patchpatch works well and the code looks very solid however unfortunately I had no time to do a detailed review/report but definitely a good candidate to merge.Comment #16
marvin_b8 commentedI have tried the patch purge-2853613-12.patch and it works as expected. I can provide screenshots if this is wanted .