Skip to content

Commit

Permalink
[CMSP-1033] Allow skipping cache control (#40)
Browse files Browse the repository at this point in the history
* add a filter to skip cache control in the mu-plugin

* adds docs for skip cache control filter
  • Loading branch information
jazzsequence authored Apr 25, 2024
1 parent 1862d38 commit fd19dc2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ Allows you to disable the ability to clear the entire cache from the WordPress a
add_filter( 'pantheon_cache_allow_clear_all', '__return_false' );
```

#### `pantheon_skip_cache_control`
Allows you to disable the cache control headers that are sent by the Pantheon Page Cache plugin.

**Default Value:** `false`

**Example:**
```php
add_filter( 'pantheon_skip_cache_control', '__return_true' );
```

### Actions
#### `pantheon_cache_settings_page_top`
Runs at the top of the Pantheon Page Cache settings page.
Expand Down
13 changes: 13 additions & 0 deletions inc/pantheon-page-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,19 @@ private function get_cache_control_header_value() {
* @return void
*/
public function cache_add_headers() {
/**
* Filter to skip the cache control header.
*
* @param bool $skip_cache_control Whether to skip the cache control header.
* @see https://github.com/pantheon-systems/pantheon-mu-plugin/issues/37
* @return bool
*/
$skip_cache_control = apply_filters( 'pantheon_skip_cache_control', false );

if ( $skip_cache_control ) {
return;
}

header( sprintf( 'cache-control: %s', $this->get_cache_control_header_value() ) );
}

Expand Down

0 comments on commit fd19dc2

Please sign in to comment.