| @@ -3,13 +3,13 @@ | ||
| 3 | 3 | |
| 4 | 4 | class WPEngine extends berqIntegrations { |
| 5 | 5 | function __construct() { |
| 6 | 6 | add_action('berqwp_flush_all_cache', [$this, 'flush_cache']); |
| 7 | - add_action('berqwp_stored_page_cache', [$this, 'flush_cache']); | |
| 7 | + add_action('berqwp_stored_page_cache', [$this, 'flush_page_cache']); | |
| 8 | 8 | add_action('berqwp_flush_page_cache', [$this, 'flush_cache']); |
| 9 | 9 | } |
| 10 | - | |
| 11 | 10 | |
| 11 | + | |
| 12 | 12 | function flush_cache() { |
| 13 | 13 | |
| 14 | 14 | if (class_exists('WpeCommon')) { |
| 15 | 15 | if ( method_exists( 'WpeCommon', 'purge_memcached' ) ) { |
| @@ -14,12 +14,29 @@ | ||
| 14 | 14 | if (class_exists('WpeCommon')) { |
| 15 | 15 | if ( method_exists( 'WpeCommon', 'purge_memcached' ) ) { |
| 16 | 16 | WpeCommon::purge_memcached(); |
| 17 | 17 | } |
| 18 | - | |
| 18 | + | |
| 19 | 19 | if ( method_exists( 'WpeCommon', 'purge_varnish_cache' ) ) { |
| 20 | 20 | WpeCommon::purge_varnish_cache(); |
| 21 | 21 | } |
| 22 | + } | |
| 23 | + } | |
| 24 | + | |
| 25 | + function flush_page_cache($slug) { | |
| 26 | + | |
| 27 | + if (empty($slug)) { | |
| 28 | + $slug = '/'; | |
| 29 | + } | |
| 30 | + | |
| 31 | + if (class_exists('WpeCommon')) { | |
| 32 | + if ( method_exists( 'WpeCommon', 'purge_memcached' ) ) { | |
| 33 | + WpeCommon::purge_memcached(); | |
| 34 | + } | |
| 35 | + | |
| 36 | + // WpeCommon::purge_varnish_cache() does not support per-URL purge; using reverse proxy purge instead | |
| 37 | + // WpeCommon::purge_varnish_cache(); | |
| 38 | + berqReverseProxyCache::purge_cache(home_url($slug)); | |
| 22 | 39 | } |
| 23 | 40 | } |
| 24 | 41 | |
| 25 | 42 | } |