2017 © Pedro Peláez
 

library wpe-cache-flush

Programmatically flush the WP Engine Cache

image

a7/wpe-cache-flush

Programmatically flush the WP Engine Cache

  • Monday, February 5, 2018
  • by a7
  • Repository
  • 2 Watchers
  • 7 Stars
  • 663 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 6 Versions
  • 13 % Grown

The README.md

WP Engine Cache Flush

Purpose

What is this?

If you host on wpengine you may be familiar with their cache system, and even more likely: their 'Purge All Caches' button:, (*1)

, (*2)

Unfortunately, WP Engine has not yet offered a programmatic way to purge the cache for your site (i.e. using a simple webhook)., (*3)

I did some digging and discovered that the functionality for the WP Engine's cache purge is all within mu-plugins and have combine the cache purging functionality and a simple webhook request to achieve a programmatic way to clear your site's cache (object cache AND varnish full page cache)., (*4)

Why would I use this?

If you deal with any sort of deployment, build, or continuous delivery system, you know how important having a programmatic way to do everything is. In this case, clearing the cache is crucial to be able to run acceptance tests and verify that the new changes have not caused any regressions., (*5)

This clears the cache for sites hosted on WP Engine., (*6)

Setup

Composer

Include via composer:, (*7)

composer require a7/wpe-cache-flush

Private Key

Create a private key., (*8)

Set the private key one of three ways:, (*9)

Constant

Define the constant WPE_CACHE_FLUSH with they key:, (*10)

define( 'WPE_CACHE_FLUSH', $private_key );

Filter

Add a filter to \A7\WPE_Cache_Flush\wpe_cache_flush_token and return the token as a string, (*11)

add_filter( '\A7\WPE_Cache_Flush\wpe_cache_flush_token', function() {
  return $private_key;
} );

Environmental Variable

Set an environmental variable for WPE_CACHE_FLUSH, (*12)

putenv( 'WPE_CACHE_FLUSH=' . $private_key );

Usage

Make a GET request to your site's URL with the query parameter ?wpe-cache-flush=$private_key., (*13)

GET http://example.com/?wpe-cache-flush=$private_key

You can also call the flush function directly from your code via, (*14)

\A7\WPE_Cache_Flush\cache_flush()

The Versions

05/02 2018

dev-master

9999999-dev

Programmatically flush the WP Engine Cache

  Sources   Download

Unlicense

The Requires

  • php >=5.5.9

 

by Avatar a7

05/02 2018

0.3.0.2

0.3.0.2

Programmatically flush the WP Engine Cache

  Sources   Download

Unlicense

The Requires

  • php >=5.5.9

 

by Avatar a7

28/06 2017

0.3.0

0.3.0.0

Programmatically flush the WP Engine Cache

  Sources   Download

Unlicense

The Requires

  • php >=5.5.9

 

by Avatar a7

14/06 2017

0.2.3

0.2.3.0

Programmatically flush the WP Engine Cache

  Sources   Download

Unlicense

The Requires

  • php >=5.5.9

 

by Avatar a7

14/06 2017

0.2.0

0.2.0.0

Programmatically flush the WP Engine Cache

  Sources   Download

Unlicense

The Requires

  • php >=5.5.9

 

by Avatar a7

14/06 2017

0.1.0

0.1.0.0

Programmatically flush the WP Engine Cache

  Sources   Download

Unlicense

The Requires

  • php >=5.5.9

 

by Avatar a7