Skip to content

Commit

Permalink
Boost: Add edge-cache header on WP Cloud (#40557)
Browse files Browse the repository at this point in the history
* Add edge-cache header on atomic

* changelog

* Update atomic check

* Add edge-cache header when uncached as well

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12439187804

Upstream-Ref: Automattic/jetpack@acacbbe
  • Loading branch information
haqadn authored and matticbot committed Dec 20, 2024
1 parent e717e4f commit 2280b14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This is an alpha version! The changes listed here are not final.
- Concatenate JS/CSS: Add a button that allows loading default excludes.
- General: Added tracks events to clickable elements on the settings page.
- General: Add WordPress filters to allow Cornerstone Pages list and Image Size Analyzer source data to be updated.
- Minify: Added HTTP header to take advantage of WordPress.com edge caching
- UI: Add notifications when interacting with dashboard settings.

### Changed
Expand Down
8 changes: 8 additions & 0 deletions app/lib/minify/functions-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 ) . '"' );
Expand Down

0 comments on commit 2280b14

Please sign in to comment.