| @@ -2,10 +2,10 @@ | ||
| 2 | 2 | if (!defined('ABSPATH')) exit; |
| 3 | 3 | |
| 4 | 4 | class Nginx extends berqIntegrations { |
| 5 | 5 | function __construct() { |
| 6 | - add_action('berqwp_flush_all_cache', [$this, 'flush_cache']); | |
| 7 | - add_action('berqwp_stored_page_cache', [$this, 'flush_cache']); | |
| 6 | + /* add_action('berqwp_flush_all_cache', [$this, 'flush_cache']); */ | |
| 7 | + add_action('berqwp_stored_page_cache', [$this, 'flush_page_cache']); | |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | function flush_cache() |
| 11 | 11 | { |
| @@ -22,7 +22,22 @@ | ||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | + | |
| 27 | + function flush_page_cache($slug) | |
| 28 | + { | |
| 29 | + $is_nginx = stripos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false; | |
| 30 | + | |
| 31 | + if (!$is_nginx) { | |
| 32 | + return; | |
| 33 | + } | |
| 34 | + | |
| 35 | + if (empty($slug)) { | |
| 36 | + $slug = '/'; | |
| 37 | + } | |
| 38 | + | |
| 39 | + berqReverseProxyCache::purge_cache(home_url($slug)); | |
| 40 | + } | |
| 26 | 41 | } |
| 27 | 42 | |
| 28 | -new Nginx(); | |
| 43 | +new Nginx(); | |