Support

Find answers, guides, and tutorials to supercharge your content delivery.

WordPress Cache Enabler Plugin

Updated on May 26, 2021

The WordPress Cache Enabler plugin is a lightweight page caching plugin that creates static HTML files and stores them on your web server. This means that a static HTML file will be delivered whenever possible to provide users with the response data that would otherwise involve the resource intensive process of using the WordPress core, plugins, and database. It supports converting inline image URLs to WebP and pre-compressing cached pages with Gzip. This simple, yet powerful plugin is easy to use, needs minimal configuration, and best of all helps improve site load time.

Installation

Installation of the WordPress Cache Enabler plugin is easy and can be done in just a few steps:

  1. Log in to your WordPress admin dashboard.
  2. In the left navigation sidebar hover over Plugins and then click Add New.
  3. Either upload the latest Cache Enabler version in .zip format, which can be directly downloaded here, or search for "Cache Enabler" and click Install Now on the plugin by KeyCDN.
  4. After the Cache Enabler plugin has been installed activate the plugin.

Cache Enabler will now be successfully installed and activated on your WordPress website. We have built this plugin to work for the majority of WordPress installations right out of the box, which means there are no required configurations or settings to make this plugin start caching your pages. However, you may want to further configure Cache Enabler to fit your needs, which can be done through the plugin settings and/or hooks.

Settings

Customizing the Cache Enabler plugin settings can be done by going to the Cache Enabler settings page. This page can be accessed by doing the following:

  1. Log in to your WordPress admin dashboard.
  2. In the left navigation sidebar hover over Settings and then click Cache Enabler.

The Cache Enabler settings page is simple and broken into two parts, Cache Behavior and Cache Exclusions. The Cache Behavior settings control the behavior of page caching, whereas the Cache Exclusions settings controls what pages should bypass the cache.

Hooks

NameTypeDescription
cache_enabler_clear_complete_cacheActionClear the complete cache.
cache_enabler_complete_cache_clearedActionFires after the complete cache has been cleared.
cache_enabler_clear_site_cacheActionClear the site cache for the current blog ID.
cache_enabler_clear_site_cache_by_blog_idActionClear the site cache for the given blog ID.
cache_enabler_site_cache_clearedActionFires after the site cache has been cleared.
cache_enabler_clear_page_cache_by_post_idActionClear the page cache for the given post ID.
cache_enabler_clear_page_cache_by_urlActionClear the page cache for the given URL.
cache_enabler_page_cache_clearedActionFires after the page cache has been cleared.
cache_enabler_clear_expired_cacheActionClear the expired cache for the current blog ID.
cache_enabler_user_can_clear_cacheFilterFilters whether the current user can clear the cache.
cache_enabler_exclude_searchFilterFilters whether search queries should bypass the cache
cache_enabler_bypass_cacheFilterFilters whether the cache should be bypassed.
cache_enabler_page_contents_before_storeFilterFilters page contents before being stored.
cache_enabler_mkdir_modeFilterFilters mode assigned to directories on creation.
cache_enabler_minify_html_ignore_tagsFilterFilters HTML tags to ignore during minification.
cache_enabler_convert_webp_attributesFilterFilters HTML attributes to convert during WebP conversion.
cache_enabler_convert_webp_ignore_query_stringsFilterFilters whether inline image URLs with query strings should be ignored during WebP conversion.
cache_enabler_page_contents_after_webp_conversionFilterFilters page contents after inline image URLs were maybe converted to WebP.
cache_enabler_page_cache_createdActionFires after the page cache has been created.

cache_enabler_clear_complete_cache

do_action( 'cache_enabler_clear_complete_cache' );

Clear the complete cache.

Source

File: inc/cache_enabler.class.php

Changelog

1.6.0 - Introduced.

Example

function clear_cache_enabler_complete_cache() {

    do_action( 'cache_enabler_clear_complete_cache' );
}

cache_enabler_complete_cache_cleared

do_action( 'cache_enabler_complete_cache_cleared' );

Fires after the complete cache has been cleared.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.6.0 - Introduced.

Example

add_action( 'cache_enabler_complete_cache_cleared', 'on_cache_enabler_complete_cache_cleared' );

function on_cache_enabler_complete_cache_cleared() {

    // code...
}

cache_enabler_clear_site_cache

do_action( 'cache_enabler_clear_site_cache' );

Clear the site cache for the current blog ID.

Source

File: inc/cache_enabler.class.php

Changelog

1.6.0 - Introduced.

Example

function clear_cache_enabler_site_cache() {

    do_action( 'cache_enabler_clear_site_cache' );
}

cache_enabler_clear_site_cache_by_blog_id

do_action( 'cache_enabler_clear_site_cache_by_blog_id', int $blog_id );

Clear the site cache for the given blog ID.

Parameters

$blog_id (int) Blog ID of site cache to clear.

Source

File: inc/cache_enabler.class.php

Changelog

1.6.0 - Introduced.

Example

$blog_id = 1;

function clear_cache_enabler_site_cache_by_blog_id( $blog_id ) {

    do_action( 'cache_enabler_clear_site_cache_by_blog_id', $blog_id );
}

cache_enabler_site_cache_cleared

do_action( 'cache_enabler_site_cache_cleared', string $site_cleared_url, int $site_cleared_id, array $cache_cleared_index );

Fires after the site cache has been cleared.

Parameters

$site_cleared_url (string) Full URL of site cleared.

$site_cleared_id (int) Blog ID of site cleared.

$cache_cleared_index (array) Index of cache cleared.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.8.0 - The $cache_cleared_index parameter was added.

1.6.0 - Introduced.

Example

add_action( 'cache_enabler_site_cache_cleared', 'on_cache_enabler_site_cache_cleared', 10, 3 );

function on_cache_enabler_site_cache_cleared( $site_cleared_url, $site_cleared_id, $cache_cleared_index ) {

    // code...
}

cache_enabler_clear_page_cache_by_post_id

do_action( 'cache_enabler_clear_page_cache_by_post_id', int $post_id );

Clear the page cache for the given post ID.

Parameters

$post_id (int) Post ID of page cache to clear.

Source

File: inc/cache_enabler.class.php

Changelog

1.6.0 - Introduced.

Example

$post_id = 1;

function clear_cache_enabler_page_cache_by_post_id( $post_id ) {

    do_action( 'cache_enabler_clear_page_cache_by_post_id', $post_id );
}

cache_enabler_clear_page_cache_by_url

do_action( 'cache_enabler_clear_page_cache_by_url', string $url );

Clear the page cache for the given URL.

Parameters

$url (string) Full URL of page cache to clear.

Source

File: inc/cache_enabler.class.php

Changelog

1.6.0 - Introduced.

Example

$url = 'https://www.example.com/about-us/';

function clear_cache_enabler_page_cache_by_url( $url ) {

    do_action( 'cache_enabler_clear_page_cache_by_url', $url );
}

cache_enabler_page_cache_cleared

do_action( 'cache_enabler_page_cache_cleared', string $page_cleared_url, int $page_cleared_id, array $cache_cleared_index );

Fires after the page cache has been cleared.

Parameters

$page_cleared_url (string) Full URL of page cleared.

$page_cleared_id (int) Post ID of page cleared.

$cache_cleared_index (array) Index of cache cleared.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.8.0 - The $cache_cleared_index parameter was added.

1.6.0 - Introduced.

Example

add_action( 'cache_enabler_page_cache_cleared', 'on_cache_enabler_page_cache_cleared', 10, 3 );

function on_cache_enabler_page_cache_cleared( $page_cleared_url, $page_cleared_id, $cache_cleared_index ) {

    // code...
}

cache_enabler_clear_expired_cache

do_action( 'cache_enabler_clear_expired_cache' );

Clear the expired cache for the current blog ID.

Source

File: inc/cache_enabler.class.php

Changelog

1.8.0 - Introduced.

Example

function clear_cache_enabler_expired_cache() {

    do_action( 'cache_enabler_clear_expired_cache' );
}

cache_enabler_user_can_clear_cache

apply_filters( 'cache_enabler_user_can_clear_cache', bool $user_can_clear_cache = current_user_can( 'manage_options' ) );

Filters whether the current user can clear the cache.

Parameters

$user_can_clear_cache (bool) Whether the current user can clear the cache. Defaults to value returned by current_user_can( 'manage_options' ).

Source

File: inc/cache_enabler.class.php

Changelog

1.6.0 - Introduced.

Example

add_filter( 'cache_enabler_user_can_clear_cache', 'current_user_can_edit_posts' );

function current_user_can_edit_posts() {

    return current_user_can( 'edit_posts' );
}

apply_filters( 'cache_enabler_exclude_search', bool $exclude_search = is_search() );

Filters whether search queries should bypass the cache.

Parameters

$exclude_search (bool) Whether search queries should bypass the cache. Defaults to value returned by is_search().

Source

File: inc/cache_enabler_engine.class.php

Changelog

1.6.0 - Introduced.

Example

add_filter( 'cache_enabler_exclude_search', '__return_false' );

cache_enabler_bypass_cache

apply_filters( 'cache_enabler_bypass_cache', bool $bypass_cache = false );

Filters whether the cache should be bypassed.

Parameters

$bypass_cache (bool) Whether the cache should be bypassed. Default is false.

Source

File: inc/cache_enabler_engine.class.php

Changelog

1.6.0 - Introduced.

Example

add_filter( 'cache_enabler_bypass_cache', '__return_true' );

cache_enabler_page_contents_before_store

apply_filters( 'cache_enabler_page_contents_before_store', string $page_contents );

Filters page contents before being stored.

Parameters

$page_contents (string) Page contents from the output buffer as raw HTML.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.6.0 - Introduced.

Example

add_filter( 'cache_enabler_page_contents_before_store', 'filter_cache_enabler_page_contents_before_store' );

function filter_cache_enabler_page_contents_before_store( $page_contents ) {

    // code...
}

cache_enabler_mkdir_mode

apply_filters( 'cache_enabler_mkdir_mode', int $mode = 0755 );

Filters mode assigned to directories on creation.

Parameters

$mode (int) Mode that defines access permissions to created directory. The mode must be an octal number, which means it should have a leading zero. Default mode is 0755.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.7.2 - Introduced.

Example

add_filter( 'cache_enabler_mkdir_mode', 'filter_cache_enabler_mkdir_mode' );

function filter_cache_enabler_mkdir_mode( $mode ) {

    return 0775;
}

cache_enabler_minify_html_ignore_tags

apply_filters( 'cache_enabler_minify_html_ignore_tags', array $ignore_tags = array( 'textarea', 'pre', 'code' ) );

Filters HTML tags to ignore during minification.

Parameters

$ignore_tags (array) HTML tags without leading < or trailing >. Default tags ignored are textarea, pre, and code.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.6.0 - Introduced.

Example

add_filter( 'cache_enabler_minify_html_ignore_tags', 'filter_cache_enabler_minify_html_ignore_tags' );

function filter_cache_enabler_minify_html_ignore_tags( $ignore_tags ) {

    $ignore_tags[] = 'canvas'; // also ignore the HTML <canvas> element

    return $ignore_tags;
}

cache_enabler_convert_webp_attributes

apply_filters( 'cache_enabler_convert_webp_attributes', array $attributes = array( 'src', 'srcset', 'data-[^=]+' ) );

Filters HTML attributes to convert during WebP conversion.

Parameters

$attributes (array) HTML attributes to convert during WebP conversion. Default attributes converted are src, srcset, and data-*.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.6.1 - Introduced.

Example

add_filter( 'cache_enabler_convert_webp_attributes', 'filter_cache_enabler_convert_webp_attributes' );

function filter_cache_enabler_convert_webp_attributes( $attributes ) {

    $attributes[] = 'href'; // also convert href attributes

    return $attributes;
}

cache_enabler_convert_webp_ignore_query_strings

apply_filters( 'cache_enabler_convert_webp_ignore_query_strings', bool $ignore_query_strings = true );

Filters whether inline image URLs with query strings should be ignored during WebP conversion.

Parameters

$ignore_query_strings (boolean) Whether inline image URLs with query strings should be ignored during WebP conversion. Default is true.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.6.1 - Introduced.

Example

add_filter( 'cache_enabler_convert_webp_ignore_query_strings', '__return_false' );

cache_enabler_page_contents_after_webp_conversion

apply_filters( 'cache_enabler_page_contents_after_webp_conversion', string $page_contents );

Filters page contents after inline image URLs were maybe converted to WebP.

Parameters

$page_contents (string) Page contents from the output buffer as raw HTML.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.6.0 - Introduced.

Example

add_filter( 'cache_enabler_page_contents_after_webp_conversion', 'filter_cache_enabler_page_contents_after_webp_conversion' );

function filter_cache_enabler_page_contents_after_webp_conversion( $page_contents ) {

    // code...
}

cache_enabler_page_cache_created

apply_filters( 'cache_enabler_page_cache_created', string $page_created_url, int $page_created_id, array $cache_created_index );

Fires after the page cache has been created.

Parameters

$page_created_url (string) Full URL of page created.

$page_created_id (int) Post ID of page created.

$cache_created_index (array) Index of cache created.

Source

File: inc/cache_enabler_disk.class.php

Changelog

1.8.0 - Introduced.

Example

add_action( 'cache_enabler_page_cache_created', 'on_cache_enabler_page_cache_created', 10, 3 );

function on_cache_enabler_page_cache_created( $page_created_url, $page_created_id, $cache_created_index ) {

    // code...
}

WP-CLI

Interact with Cache Enabler from the command line by either clearing the cache or updating the settings. This can be done through WP-CLI with the cache-enabler and option commands.

cache-enabler

Clear the cache with the cache-enabler command and clear subcommand.

Options

--ids=<id>
Clear the cache for given post ID(s). Separate multiple IDs with commas.

--urls=<url>
Clear the cache for the given URL(s). Separate multiple URLs with commas.

--sites=<site>
Clear the cache for the given blog ID(s). Separate multiple blog IDs with commas.

Examples

# Clear all pages cache.
$ wp cache-enabler clear

# Clear the page cache for post IDs 1, 2, and 3.
$ wp cache-enabler clear --ids=1,2,3

# Clear the page cache for a particular URL.
$ wp cache-enabler clear --urls=https://www.example.com/about-us/

# Clear all pages cache for sites with blog IDs 1, 2, and 3.
$ wp cache-enabler clear --sites=1,2,3

option

Update the settings with the option command and update subcommand.

ParameterDescriptionValue
versionPlugin version.string
permalink_structureWhether or not permalink structure has trailing slash.has_trailing_slash, no_trailing_slash, or plain
string
cache_expiresWhether or not cached pages expire.0 or 1
integer
cache_expiry_timeCache expiry measured in hours.integer
clear_site_cache_on_saved_postClear the site cache if any post type has been published, updated, or trashed (instead of only the page and/or associated cache).0 or 1
integer
clear_site_cache_on_saved_commentClear the site cache if a comment has been posted, updated, spammed, or trashed (instead of only the page cache).0 or 1
integer
clear_site_cache_on_changed_pluginClear the site cache if a plugin has been activated, updated, or deactivated.0 or 1
integer
convert_image_urls_to_webpCreate a cached version for WebP support. Convert your images to WebP with Optimus.0 or 1
integer
mobile_cacheCreate a cached version for mobile devices.0 or 1
integer
compress_cacheCreate a cached version pre-compressed with Gzip.0 or 1
integer
minify_htmlMinify HTML in cached pages.0 or 1
integer
minify_inline_css_jsMinify inline CSS and JavaScript when minifying HTML.0 or 1
integer
excluded_post_idsPost IDs separated by a , that should bypass the cache.string
excluded_page_pathsA regex matching page paths that should bypass the cache.string
excluded_query_stringsA regex matching query strings that should bypass the cache.string
excluded_cookiesA regex matching cookies that should bypass the cache.string

Example

# Enable WebP and Gzip versions with full HTML minification.
$ wp option update cache_enabler \
'{
    "version": "1.7.1",
    "permalink_structure": "has_trailing_slash",
    "cache_expires": 0,
    "cache_expiry_time": 0,
    "clear_site_cache_on_saved_post": 0,
    "clear_site_cache_on_saved_comment": 0,
    "clear_site_cache_on_changed_plugin": 0,
    "convert_image_urls_to_webp": 1,
    "mobile_cache": 0,
    "compress_cache": 1,
    "minify_html": 1,
    "minify_inline_css_js": 1,
    "excluded_post_ids": "",
    "excluded_page_paths": "",
    "excluded_query_strings": "",
    "excluded_cookies": ""
}' \
--format=json

Advanced configuration

A more advanced configuration can be implemented to bypass PHP entirely for even faster delivery of cached pages. The following configuration snippets can be implemented on Apache or Nginx servers. The advanced configuration snippets should only be used by those who are experienced in modifying server configuration files. Furthermore, the default Cache Enabler setup should satisfy the majority of use-cases.

Note: This configuration is optional and is not required in order to use the Cache Enabler plugin. It is only an optional configuration for those who want to entirely bypass PHP if a static HTML file exists. This configuration will not take into account the cached page expiration and some exclusion settings.

Apache

Add the following snippet before the # BEGIN WordPress section in your .htaccess file if you are using Apache 2.3.9 or later. Uncomment any cache keys that you need to use based on your Cache Enabler settings.

If you have installed WordPress in a subdirectory the CE_CACHE_DIR variable needs to be adjusted accordingly. For example, http://www.example.com/blog would require a change from CE_CACHE_DIR=/wp-content/cache/cache-enabler to CE_CACHE_DIR=/blog/wp-content/cache/cache-enabler.

# BEGIN Cache Enabler

<IfModule mod_rewrite.c>
    <IfModule mod_setenvif.c>
        RewriteEngine On
        RewriteBase /

        # cache directory
        SetEnvIf Host ^ CE_CACHE_DIR=/wp-content/cache/cache-enabler

        # default cache keys
        SetEnvIf Host ^ CE_CACHE_KEY_SCHEME http-
        SetEnvIf Host ^ CE_CACHE_KEY_DEVICE
        SetEnvIf Host ^ CE_CACHE_KEY_WEBP
        SetEnvIf Host ^ CE_CACHE_KEY_COMPRESSION

        # scheme cache key
        RewriteCond %{HTTPS} ^(on|1)$ [OR]
        RewriteCond %{SERVER_PORT} =443 [OR]
        RewriteCond %{HTTP:X-Forwarded-Proto} =https [OR]
        RewriteCond %{HTTP:X-Forwarded-Scheme} =https
        RewriteRule ^ - [E=CE_CACHE_KEY_SCHEME:https-]

        # device cache key
        # SetEnvIf User-Agent "(Mobile|Android|Silk/|Kindle|BlackBerry|Opera Mini|Opera Mobi)" CE_CACHE_KEY_DEVICE=-mobile

        # webp cache key
        # SetEnvIf Accept image/webp CE_CACHE_KEY_WEBP=-webp

        # compression cache key
        # <IfModule mod_mime.c>
        #     SetEnvIf Accept-Encoding gzip CE_CACHE_KEY_COMPRESSION=.gz
        #     AddType text/html .gz
        #     AddEncoding gzip .gz
        # </IfModule>

        # get cache file
        SetEnvIf Host ^ CE_CACHE_FILE_DIR=%{ENV:CE_CACHE_DIR}/%{HTTP_HOST}%{REQUEST_URI}
        SetEnvIf Host ^ CE_CACHE_FILE_NAME=%{ENV:CE_CACHE_KEY_SCHEME}index%{ENV:CE_CACHE_KEY_DEVICE}%{ENV:CE_CACHE_KEY_WEBP}.html%{ENV:CE_CACHE_KEY_COMPRESSION}
        SetEnvIf Host ^ CE_CACHE_FILE=%{ENV:CE_CACHE_FILE_DIR}/%{ENV:CE_CACHE_FILE_NAME}

        # check if cache file exists
        RewriteCond %{DOCUMENT_ROOT}%{ENV:CE_CACHE_FILE} -f

        # check request method
        RewriteCond %{REQUEST_METHOD} =GET

        # check permalink structure has trailing slash
        RewriteCond %{REQUEST_URI} /[^\./\?]+(\?.*)?$
        # check permalink structure has no trailing slash
        # RewriteCond %{REQUEST_URI} /[^\./\?]+/(\?.*)?$

        # check excluded query strings
        RewriteCond %{QUERY_STRING} !^(?!(fbclid|ref|mc_(cid|eid)|utm_(source|medium|campaign|term|content|expid)|gclid|fb_(action_ids|action_types|source)|age-verified|usqp|cn-reloaded|_ga|_ke)).+$

        # check excluded cookies
        RewriteCond %{HTTP_COOKIE} !(wp-postpass|wordpress_logged_in|comment_author)_

        # deliver cache file
        RewriteRule ^ %{ENV:CE_CACHE_FILE} [L]
    </IfModule>
</IfModule>

# END Cache Enabler

Nginx

Add the following snippet to your Nginx configuration file. Uncomment any cache keys that you need to use based on your Cache Enabler settings.

If you have installed WordPress in a subdirectory the $ce_cache_dir variable needs to be adjusted accordingly. For example, http://www.example.com/blog would require a change from /wp-content/cache/cache-enabler to /blog/wp-content/cache/cache-enabler. Further, using a subdirectory may also require that the location block be updated to contain the subdirectory.

server {

    ...

    # cache directory
    set $ce_cache_dir '/wp-content/cache/cache-enabler';

    # default cache keys
    set $ce_cache_key_scheme      'http-';
    set $ce_cache_key_device      '';
    set $ce_cache_key_webp        '';
    set $ce_cache_key_compression '';

    # scheme cache key
    if ( $scheme = https ) {
        set $ce_cache_key_scheme 'https-';
    }
    # if ( $server_port = 443 ) {
    #     set $ce_cache_key_scheme 'https-';
    # }
    # if ( $http_x_forwarded_proto = https ) {
    #     set $ce_cache_key_scheme 'https-';
    # }
    # if ( $http_x_forwarded_scheme = https ) {
    #     set $ce_cache_key_scheme 'https-';
    # }

    # device cache key
    # if ( $http_user_agent ~ '(Mobile|Android|Silk/|Kindle|BlackBerry|Opera Mini|Opera Mobi)' ) {
    #    set $ce_cache_key_device '-mobile';
    # }

    # webp cache key
    # if ( $http_accept ~ image/webp ) {
    #     set $ce_cache_key_webp '-webp';
    # }

    # compression cache key
    # if ( $http_accept_encoding ~ gzip ) {
    #     set $ce_cache_key_compression '.gz';
    # }

    # get cache file
    set $ce_cache_file_dir  ${ce_cache_dir}/${http_host}${request_uri};
    set $ce_cache_file_name ${ce_cache_key_scheme}index${ce_cache_key_device}${ce_cache_key_webp}.html${ce_cache_key_compression};
    set $ce_cache_file      ${ce_cache_file_dir}/${ce_cache_file_name};

    location / {
        error_page 405 = @fallback;
        recursive_error_pages on;

        # check request method
        if ( $request_method != GET ) {
            return 405;
        }

        # check permalink structure has trailing slash
        if ( $request_uri !~ /[^\./\?]+(\?.*)?$ ) {
            return 405;
        }
        # check permalink structure has no trailing slash
        # if ( $request_uri !~ /[^\./\?]+/(\?.*)?$ ) {
        #    return 405;
        # }

        # check excluded query strings
        if ( $query_string ~ ^(?!(fbclid|ref|mc_(cid|eid)|utm_(source|medium|campaign|term|content|expid)|gclid|fb_(action_ids|action_types|source)|age-verified|usqp|cn-reloaded|_ga|_ke)).+$ ) {
            return 405;
        }

        # check excluded cookies
        if ( $http_cookie ~ (wp-postpass|wordpress_logged_in|comment_author)_ ) {
            return 405;
        }

        # deliver cache file if it exists
        try_files $ce_cache_file @fallback;
    }

    location @fallback {
        try_files $uri $uri/ /index.php?$args;
    }

    ...

}

FAQ

Find answers to commonly asked questions about Cache Enabler. Still have questions? Open a new topic in the WordPress Support Forums and we would be happy to help.

How can I check if Cache Enabler is working on my site?

You can quickly verify that the Cache Enabler is delivering a cached version of a specific page by logging out of your WordPress installation and checking the bottom of your page source for the Cache Enabler HTML comment, for example:

<!-- Cache Enabler by KeyCDN @ Wed, 24 Mar 2021 00:00:00 GMT (https-index-webp.html.gz) -->

Alternatively, check the response headers of the HTML page for X-Cache-Handler: cache-enabler-engine if the advanced configuration is not used.

What is performed when Cache Enabler is activated?

Upon activation, Cache Enabler will first setup the backend by adding or updating the database. Next, it will copy the advanced-cache.php file from the wp-content/plugins/cache-enabler directory to the wp-content directory. Lastly, it will add the following snippet to the wp-config.php file if the WP_CACHE constant is not found and the config file is the default:

/** Enables page caching for Cache Enabler. */
if ( ! defined( 'WP_CACHE' ) ) {
    define( 'WP_CACHE', true );
}
Note: The wp-content/advanced-cache.php drop-in and having WP_CACHE constant defined as true are required for Cache Enabler to cache and deliver pages.

What is performed when Cache Enabler is deactivated?

Upon deactivation, Cache Enabler will first delete the advanced-cache.php file from the wp-content directory. Next, it will remove the snippet added by Cache Enabler in the wp-config.php file. Lastly, it will clear the complete cache.

What is performed when Cache Enabler is uninstalled?

Upon uninstallation, Cache Enabler will delete the single database option that was added during the initial plugin activation.

What happens when any post type is published, updated, or trashed?

By default, when any post type is published the associated cache will be cleared. When any post type is updated or trashed the page and associated cache will be cleared. The associated cache is any pages that are associated with the new or existing page, which could be the post type, taxonomy, author, or date archives page. This ensures pages that will contain the new page or pages that already contain an existing page are cleared.

The ability to clear the site cache instead is possible through the available Cache Enabler clearing setting.

Can I clear the cache of a specific page?

Yes. You can clear the cache of a specific page by going to that page and clicking the "Clear Page Cache" button in the WordPress admin bar.

How does the WebP cached version work?

Cache Enabler parses the page contents and replaces inline image URLs with the WebP formatted image if it exists. This will work for images with the extension replaced, such as example.webp, or images with the extension appended, such as example.jpg.webp. This page is then cached separately and is delivered when accepted and the cached page with the default format(s) will be delivered when not.

How can I convert my images to WebP?

To convert your images to WebP, use the Cache Enabler plugin in conjunction with the Optimus image optimizer plugin.

How do I use Cache Enabler on a multisite network?

Using the Cache Enabler plugin on a multisite network is quite straightforward. Once the plugin is installed you can either network activate it and it will start working for each site in the network, or you can activate Cache Enabler on each site individually that you want it running on. The cache and settings are configured to work individually for each site. Therefore, you can clear the cache on site 1, while site 2 and 3 will retain their cache.

Network settings are not currently available but we intend on introducing this in future (#123).

No. Cache Enabler does not work with default permalinks.

Does Cache Enabler work with mobile themes if the desktop and mobile versions are different?

Yes. Cache Enabler has the ability to create a separate mobile cache.

Will cached page expiration still work if the advanced configuration is used?

No. Cache Enabler's ability to automatically expire the cached page based on a defined period will no longer work as the PHP calls required for that function will be bypassed.

However, a cron job may be created in order to continue expiring the cache automatically. Add the following command to your cron job once you have determined the time period for which you would like the cache to expire:

*/1 * * * * rm -rf /path/to/your/wordpress/wp-content/cache/cache-enabler/

How can I verify if the advanced configuration is bypassing PHP?

By adding the advanced configuration snippet to your server you have the ability to bypass PHP in order to retrieve the static HTML file that was created by the WordPress Cache Enabler plugin. In order to ensure that you are in fact bypassing PHP after you've added the snippet, open up your developer tools, navigate to the Network panel and select the HTML file of your page.

If you've added the advanced configuration snippet successfully, the X-Cache-Handler: cache-enabler-engine response header will no longer be set, which means the Cache Enabler engine, which is powered by PHP, is no longer handling the delivery. If this response header is not present and the Cache Enabler HTML comment is still in the page source then your advanced configuration is properly implemented.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more about cookies.