From acacbbe34e341fb2e5b4825b506f6d16e6fd0858 Mon Sep 17 00:00:00 2001 From: Adnan Haque <3737780+haqadn@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:11:15 -0500 Subject: [PATCH] Boost: Add edge-cache header on WP Cloud (#40557) * Add edge-cache header on atomic * changelog * Update atomic check * Add edge-cache header when uncached as well --- .../plugins/boost/app/lib/minify/functions-service.php | 8 ++++++++ projects/plugins/boost/changelog/add-edge-cache-header | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 projects/plugins/boost/changelog/add-edge-cache-header diff --git a/projects/plugins/boost/app/lib/minify/functions-service.php b/projects/plugins/boost/app/lib/minify/functions-service.php index 20812b65b62d2..08fbd8997447d 100644 --- a/projects/plugins/boost/app/lib/minify/functions-service.php +++ b/projects/plugins/boost/app/lib/minify/functions-service.php @@ -60,6 +60,10 @@ function jetpack_boost_page_optimize_service_request() { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents $etag = '"' . md5( file_get_contents( $cache_file ) ) . '"'; + // Check if we're on Atomic and take advantage of the Atomic Edge Cache. + if ( defined( 'ATOMIC_CLIENT_ID' ) ) { + header( 'A8c-Edge-Cache: cache' ); + } header( 'X-Page-Optimize: cached' ); header( 'Cache-Control: max-age=' . 31536000 ); header( 'ETag: ' . $etag ); @@ -77,6 +81,10 @@ function jetpack_boost_page_optimize_service_request() { foreach ( $headers as $header ) { header( $header ); } + // Check if we're on Atomic and take advantage of the Atomic Edge Cache. + if ( defined( 'ATOMIC_CLIENT_ID' ) ) { + header( 'A8c-Edge-Cache: cache' ); + } header( 'X-Page-Optimize: uncached' ); header( 'Cache-Control: max-age=' . 31536000 ); header( 'ETag: "' . md5( $content ) . '"' ); diff --git a/projects/plugins/boost/changelog/add-edge-cache-header b/projects/plugins/boost/changelog/add-edge-cache-header new file mode 100644 index 0000000000000..534f4a2e449ff --- /dev/null +++ b/projects/plugins/boost/changelog/add-edge-cache-header @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Minify: Added HTTP header to take advantage of WordPress.com edge caching