diff --git a/admin/class-fastcgi-purger.php b/admin/class-fastcgi-purger.php index cce53b5..db2d39b 100644 --- a/admin/class-fastcgi-purger.php +++ b/admin/class-fastcgi-purger.php @@ -90,8 +90,29 @@ public function purge_url( $url, $feed = true ) { break; } + + if( ( is_page() || is_single() ) && $nginx_helper_admin->options['purge_amp_urls'] ) { + $this->purge_amp_version( $url ); + } } + + /** + * Purge AMP version of a URL. + * + * @param string $url_base The base URL to purge. + */ + private function purge_amp_version( $url_base ) { + $amp_url = sprintf( '%s/amp/', rtrim( $url_base, '/' ) ); + + $this->log( '- Purging AMP URL | ' . $amp_url ); + + if ( 'unlink_files' === $this->nginx_helper_admin->options['purge_method'] ) { + $this->delete_cache_file_for( $amp_url ); + } else { + $this->do_remote_get( $amp_url ); + } + } /** * Function to custom purge urls. diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index a398714..b425757 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -288,6 +288,7 @@ public function nginx_helper_default_settings() { 'redis_password' => '', 'purge_url' => '', 'redis_enabled_by_constant' => 0, + 'purge_amp_urls' => 1, 'redis_socket_enabled_by_constant' => 0, 'redis_acl_enabled_by_constant' => 0, 'preload_cache' => 0, diff --git a/admin/partials/nginx-helper-general-options.php b/admin/partials/nginx-helper-general-options.php index c3794ea..82a6c66 100644 --- a/admin/partials/nginx-helper-general-options.php +++ b/admin/partials/nginx-helper-general-options.php @@ -46,6 +46,7 @@ 'purge_page_on_deleted_comment', 'purge_feeds', 'smart_http_expire_form_nonce', + 'purge_amp_urls', 'preload_cache', ); @@ -641,6 +642,38 @@ + + + + + +
+

+ +

+
+
+ + +   + + + + +
+
+