How to Modify Your Cache Control Header in Pressable

Category: Speed | Last modified: August 28, 2020

By default, Pressable’s CDN will set the cache-control: max-age to 7 days — unless the asset has a parameter, in which case it will be 10 years. If you’d like to increase this amount of time, you may do so by appending any parameter to your static assets.

That parameter will increase the time the asset remains cached from 7 days to 10 years.

The following code snippet as a plugin will allow you to extend the cache control for all jpeg, jpg, gif, png, bmp, ico, js and css files.

Plugin Name: Pressable CDN Extender
Plugin URI:
Description: Extend Pressable's cache-control from 7 days until 10 years for static assets
Version: 1.0
Author: YourName
Author URI:

function pressablecdn_template_redirect() {
  ob_start( 'pressablecdn_ob_call' );

function pressablecdn_ob_call( $html ) {
  $cdn_extensions = array('.jpg','.jpeg','.gif','.png','.css','.bmp','.js','.ico');
  foreach ( $cdn_extensions as $cdn_extension ) {
    $html = str_replace($cdn_extension, $cdn_extension.'?extend', $html);
  return $html;

if( !is_admin() && strpos($_SERVER['DOCUMENT_URI'],"wp-admin") === false && strpos($_SERVER['DOCUMENT_URI'],"wp-login.php") === false ) {
  add_action( 'template_redirect', 'pressablecdn_template_redirect');

You can verify that the cache-control headers have changed by running the following curl commands for the static asset(s) in question:

$ curl -sI | grep ^cache-control
cache-control: max-age=604800
$ curl -sI | grep ^cache-control
cache-control: max-age=315360000
An Automattic Invention A family of WordPress solutions.