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.

Issue fork purge-2853613

Command icon 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

VitalyM created an issue. See original summary.

vitalym’s picture

StatusFileSize
new15.48 KB

Here is a patch that solves this issue. It works almost the same way drush p-invalidate or PurgeBlock do.

vitalym’s picture

StatusFileSize
new52.24 KB
new82.13 KB

Adding screenshots for better vision.

vitalym’s picture

Status: Active » Needs review
firewaller’s picture

Status: Needs review » Reviewed & tested by the community

This 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?

vitalym’s picture

@firewaller If you take a look at code around the line

$this->purgePurgers->invalidate($this->processor, $invalidations);

in the patch, you may build your own code to invalidate automatically w/o a form.

firewaller’s picture

@VitalyM thanks! I figured it out.

eleonel’s picture

Hi, 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.

joseph.olstad’s picture

hi 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.

fengtan’s picture

StatusFileSize
new15.43 KB
new2.01 KB

Patch #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/2774931

Attached is a new patch that replaces drupal_set_message() with \Drupal\Core\Messenger\MessengerInterface::addMessage() as recommended by the change record above.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 10: purge-2853613-10.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

fengtan’s picture

Status: Needs work » Needs review
StatusFileSize
new639 bytes
new16.02 KB

Somehow 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!

fengtan’s picture

StatusFileSize
new16.06 KB
new707 bytes

Patch does not apply anymore against 8.x-3.x -- re-rolled

baluertl’s picture

Issue tags: +ui, +admin interface
junkuncz’s picture

purge-2853613-12.patch patch 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.

marvin_b8’s picture

Status: Needs review » Reviewed & tested by the community

I have tried the patch purge-2853613-12.patch and it works as expected. I can provide screenshots if this is wanted .

japerry made their first commit to this issue’s fork.