Skip to content

Commit

Permalink
update rest api no-cache example code (#9160)
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence authored Aug 9, 2024
1 parent f4f09d3 commit b7c9825
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/content/cache-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ $regex_json_path_patterns = array(
foreach ($regex_json_path_patterns as $regex_json_path_pattern) {
if (preg_match($regex_json_path_pattern, $_SERVER['REQUEST_URI'])) {
// re-use the rest_post_dispatch filter in the Pantheon page cache plugin
add_filter( 'rest_post_dispatch', 'filter_rest_post_dispatch_send_cache_control', 12, 2 );
add_filter( 'rest_post_dispatch', 'filter_rest_post_dispatch_send_cache_control', 12 );
break;
}
}

// Re-define the send_header value with any custom Cache-Control header
function filter_rest_post_dispatch_send_cache_control( $response, $server ) {
$server->send_header( 'Cache-Control', 'no-cache, must-revalidate, max-age=0' );
function filter_rest_post_dispatch_send_cache_control( $response ) {
$response->header( 'Cache-Control', 'no-cache, must-revalidate, max-age=0' );
return $response;
}
```
Expand Down

0 comments on commit b7c9825

Please sign in to comment.