Cache control by Cacholong

Description

“Cache control by Cacholong” plugin automates purging of Nginx Pagespeed cache and Nginx FastCGI cache on your Nginx server(s). It is a backend plugin that is able to:

  • Purge Nginx Pagespeed cache and/or Nginx FastCGI cache.
  • Purge caches on one or more servers (See hosts.json section for more details).
  • Remove id tag from stylesheet link tags, in order to allow Nginx Pagespeed to combine stylesheets.
  • Allow purging of other cached items (see Settings > Cache control).
  • Inform user of purge status.

When will it purge?

This plugin will work with default and custom post types. It will purge on a save, regular update, quick edit update, slug change, delete and undelete. The user is informed with one or more messages.
There is one caveat: When the user uses “Quick edit” and “Updates” the post, no messages will be displayed, because there’s no page refresh. Those messages will be shown on the next request.

You can also purge items manually. Go to the WordPress dashboard and navigate to:

  • Settings > Cache control > purge single item
  • Settings > Cache control > purge all caches
  • Admin Toolbar > purge all caches

Settings

  • File with hosts (JSON): File with information about one or more hosts for this WordPress installation. See hosts.json section for more details.
  • Pagespeed optimized CSS: Remove ID tag from all WordPress stylesheet link tags to improve Nginx Pagespeed caching.
  • Purge settings default post types: Select one or more options when purging a default post type. Possible to purge post url (default), home page, all connected WordPress categories or all caches.
  • Purge settings default custom type(s): Select one or more options when purging a custom post type. Possible to purge post url (default), home page, all connected WordPress categories or all caches.

hosts.json

Hosts.json is a JSON file with information about one or more servers for this WordPress installation. Remember that this file must contain information about all servers, including this one.
Default path is: /uploads/cachelong-cache-control/hosts.json.

Here is an example of a hosts.json file:

{"servers":
    [
        {"name": "server1", "ip": "127.0.0.1", "pagespeed": true, "fastcgi": false},
        {"name": "server2", "ip": "127.0.0.2", "pagespeed": false, "fastcgi": true},
    ]
}

Each line contains information about one server. Parameters:

name string Name of host, something to identify this server.
ip string IP address of server or full url. Format: scheme://host:port/path
pagespeed bool Server uses Nginx Pagespeed (true) or not (false)
fastcgi bool Server user Nginx FastCGI (true) or not (false)

When there is no hosts.json or the path is invalid, this plugin assumes the following:

{"servers":
    [
        {"name": "localhost", "ip": "127.0.0.1", "pagespeed": true, "fastcgi": true}
    ]
}

How does it work

“Cache control by Cacholong” empties partial or full cache for Nginx Pagespeed and FastCGI cache. WordPress HTTP API is used to make (post) request to
specific urls to trigger purges. Based on the http header responses this plugin determines if a purge is successful or not. The user is informed with messages, which are loaded after a purge and page refresh.

There are several settings to tweak purging, see Settings > Cache control.

Debug

Plugin will only log information when WP_DEBUG is true (can be set in wp-config.php).

Screenshots

  • “Cache control by Cacholong" settings panel.

Installation

Minimum Requirements

  • WordPress 4.3.1+
  • Nginx server with fastcgi_cache enabled

    Within the configuration of Nginx the variable $_SERVER[‘CC_NGINX_FASTCGI_CACHE_PATH’] must be provided containing the correct NGINX FASTCGI cache path. For documentation regarding Nginx setup please follow this link http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html.

Optional Requirements

  • hosts.json file. File contains information about hosts and which caches are active. See hosts.json section for more details. When not available, plugin assumes localhost with all caches active.

Automatic installation

  1. Log in to your WordPress dashboard and navigate to the plugins menu.
  2. Click “Add New”.
  3. Search for “Cache control by Cacholong”.
  4. Once you find our plugin, click “Install Now”.
  5. Activate the plugin
  6. Configure the plugin at Settings > Cache control

Manual installation

  1. Log in to your WordPress dashboard and navigate to the plugins menu.
  2. Click “Add New”.
  3. Click “Upload Plugin”.
  4. Locate zip file on your computer and click “Install Now”.
  5. Activate the plugin
  6. Configure the plugin at Settings > Cache control

Updating

Although our updates are thoroughly tested, make a backup of your website (files and database) before you install an update. Just to be sure!

FAQ

Installation Instructions

Minimum Requirements

  • WordPress 4.3.1+
  • Nginx server with fastcgi_cache enabled

    Within the configuration of Nginx the variable $_SERVER[‘CC_NGINX_FASTCGI_CACHE_PATH’] must be provided containing the correct NGINX FASTCGI cache path. For documentation regarding Nginx setup please follow this link http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html.

Optional Requirements

  • hosts.json file. File contains information about hosts and which caches are active. See hosts.json section for more details. When not available, plugin assumes localhost with all caches active.

Automatic installation

  1. Log in to your WordPress dashboard and navigate to the plugins menu.
  2. Click “Add New”.
  3. Search for “Cache control by Cacholong”.
  4. Once you find our plugin, click “Install Now”.
  5. Activate the plugin
  6. Configure the plugin at Settings > Cache control

Manual installation

  1. Log in to your WordPress dashboard and navigate to the plugins menu.
  2. Click “Add New”.
  3. Click “Upload Plugin”.
  4. Locate zip file on your computer and click “Install Now”.
  5. Activate the plugin
  6. Configure the plugin at Settings > Cache control

Updating

Although our updates are thoroughly tested, make a backup of your website (files and database) before you install an update. Just to be sure!

Why doesn’t this plugin work?

This plugin has several requirements. Please check the minimum and optional requirements, before installing this plugin. Open a support topic if you
require additional help.

When i use “Quick edit” to edit a post, nothing is happening!

Although no message is displayed, the purge was activated! You can see the purge message when you refresh the page. This is a technical limitation.

Contributors & Developers

“Cache control by Cacholong” is open source software. The following people have contributed to this plugin.

Contributors

Changelog

4.0.1 – 2018-03-14

  • Changed – Small improvement to readme.txt.

4.0.0 – 2018-02-26

  • Added – license.txt file
  • Added – Fingerprinting for assets
  • Changed – Plugin name change from Cache helper by Cacholong -> Cache control by Cacholong
  • Changed – Small changes in author / copyright
  • Changed – Language files updated
  • Changed – All php / phtml / js files a copyright / license block
  • Changed – Namespaced all classes
  • Changed – Improved prefix on all global functions cc_ -> cacholong_cc_
  • Changed – All namespaces to fully qualified names
  • Changed – Javascipt prefixes from cc_ -> cacholong_cc
  • Changed – WordPress HTTP API is used instead of (custom) curl (wrapper).
  • Deprecated – Curl class.

3.2.1 – 2018-01-25

  • Fixed – Small fix for showing ‘delay text’.

3.2.0 – 2018-01-24

  • Changed – Only show ‘delay text’ for pagespeed when purge was succesful, instead of always.

3.1.1 – 2016-09-14

  • Fixed – Removed a few purge hooks from is_admin() to work again.

3.1.0 – 2017-12-22

  • Added – Delay text message for all purges.
  • Fixed – Handle non-array admin messages.
  • Changed – userOptions table is now used to handle session flash data, session handling is removed.
  • Changed – is_admin() to optimize performance frontend.
  • Changed – Removed log message for missing hosts json file, not needed anymore.
  • Changed – Language files updated.
  • Changed – Improvements in messages, phpDoc and debugging.
  • Deprecated – Sessions class.

3.0.0 – 2017-12-15

  • Added – Setting to enable or disable removing id attribute from stylesheet link tag. Nginx pagespeed needs css id removed to combine stylesheets.

See changelog.txt for all versions.