From 6743073a0f5aa3a3c51542d14ebd2b63767cf893 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 17 Jun 2020 15:02:09 -0300 Subject: [PATCH 1/2] introduce woocommerce_enable_nocache_headers filter --- includes/class-wc-cache-helper.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-cache-helper.php b/includes/class-wc-cache-helper.php index 5d64df5d8f7..82e33f515ce 100644 --- a/includes/class-wc-cache-helper.php +++ b/includes/class-wc-cache-helper.php @@ -40,8 +40,15 @@ class WC_Cache_Helper { * @since 3.6.0 */ public static function additional_nocache_headers( $headers ) { - // no-transform: Opt-out of Google weblight if page is dynamic e.g. cart/checkout. https://support.google.com/webmasters/answer/6211428?hl=en. - $headers['Cache-Control'] = 'no-transform, no-cache, no-store, must-revalidate'; + /** + * Allow CDN plugins to disable nocache headers. + * + * @param bool $enable_nocache_headers Flag indicating whether to add nocache headers. Default: true. + */ + if ( apply_filters( 'woocommerce_enable_nocache_headers', true ) ) { + // no-transform: Opt-out of Google weblight if page is dynamic e.g. cart/checkout. https://support.google.com/webmasters/answer/6211428?hl=en. + $headers['Cache-Control'] = 'no-transform, no-cache, no-store, must-revalidate'; + } return $headers; } From 4a9fb66a39f15bafa9d47e540b771edc3749250a Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Thu, 18 Jun 2020 10:56:31 -0300 Subject: [PATCH 2/2] update comment to accurate description --- includes/class-wc-cache-helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-cache-helper.php b/includes/class-wc-cache-helper.php index 82e33f515ce..6863411df0f 100644 --- a/includes/class-wc-cache-helper.php +++ b/includes/class-wc-cache-helper.php @@ -46,7 +46,7 @@ class WC_Cache_Helper { * @param bool $enable_nocache_headers Flag indicating whether to add nocache headers. Default: true. */ if ( apply_filters( 'woocommerce_enable_nocache_headers', true ) ) { - // no-transform: Opt-out of Google weblight if page is dynamic e.g. cart/checkout. https://support.google.com/webmasters/answer/6211428?hl=en. + // no-transform: Opt-out of Google weblight. https://support.google.com/webmasters/answer/6211428?hl=en. $headers['Cache-Control'] = 'no-transform, no-cache, no-store, must-revalidate'; } return $headers;