Last active
October 19, 2021 14:25
-
-
Save henshaw/29b34807f393f24c9a258db685a987e6 to your computer and use it in GitHub Desktop.
The WordPress HTTP header must have cache-control set to must-revalidate for Signed Exchanges (SXG) to work with Cloudflare on Google Search. This code must be added to the theme's functions.php file. Additionally, the Browser Cache TTL on Cloudflare must be set to Respect Existing Headers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add cache-control headers to response | |
*/ | |
function add_cache_control_headers() { | |
if (!is_admin()) { | |
header("Cache-Control: public, must-revalidate, max-age=3600"); | |
} | |
} | |
add_action( 'template_redirect', 'add_cache_control_headers' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code was originally found from this article: https://barebones.dev/articles/cloudflare-enable-full-page-caching-with-wordpress/