NGINX Cache Controller Configuration Settings

This post will cover more details on Nginx Cache Controller Plugin basic settings and “how to configure and use Nginx Cache Controller”.

It should be noted that there is no need to change the settings in Amimoto AMI, because it is already completed, but please check when it is done so you can customize the settings on your own.

“Nginx Cache Controller” will work with under the following settings by default:

The settings for the validity period of the cache

In Nginx Cache Controller, it is now possible to set the validity period of a separate cache for each type of page.

Screen Shot 2015-01-27 at 12.40.38

This feature has been achieved by Nginx Cache Controller plugin to specify the validity period for the reverse proxy by using the X-Accel-Expires header.

However, because the default specification of Nginx ignores  X-Accel-Expires header received from fastcgi, you need to revise the settings below to give permission to some response header including X-Accel-Expires.

For reference, the default settings of Amimoto AMI looks like the following:

location ~ \ .php $ {
    ...
    ...
    fastcgi_pass_header "X-Accel-Redirect";
    fastcgi_pass_header "X-Accel-Buffering";
    fastcgi_pass_header "X-Accel-Charset";
    fastcgi_pass_header "X-Accel-Expires";
    fastcgi_pass_header "X-Accel-Limit-Rate";
    ...
}

Settings for automatic deletion of cache

To do automatic deletion of the cache of Nginx Cache Controller, you must meet the following conditions.

  • Yes  to “Enable Cache Delete”
  • the path of reverse proxy cache and path of the cache Nginx Cache Controller must be the same.
  • With respect to caching reverse proxy, have written permission from WordPress (web server back-end).

Screen Shot 2015-01-27 at 12.43.02

The settings of Nginx based on the above image will be as follows.

Setting proxy_cache_path

This is the configuration example of Nginx which is same as the default of Nginx Cache Controller

proxy_cache_path / var / cache / nginx levels = 1: 2
    keys_zone = czone: 32m max_size = 256m inactive = 1440m;

The following is an example of Amimoto AMI:

proxy_cache_path / var / cache / nginx / proxy_cache levels = 1: 2
    keys_zone = czone: 32m max_size = 256m inactive = 1440m;

In the two examples introduced above, the important ones that should be in common are the value of the path, like / var / Cache / nginx and / var / cache / nginx / proxy_cach, and the value of levels such as, 1: 2

If these do not match the Nginx Cache Controller’s settings, it will not be able to find the path to the cache and you cannot delete the cache.

Screen Shot 2015-01-27 at 12.45.13

Setting proxy_cache_key

Nginx reverse proxy generate and cache upon request from the browser URL and save proxy_cache_key value converted to md5 hash values to the original file name.

In Nginx Cache Controller, delete the cache on the assumption that the value of proxy_cache_key has become as follows.

proxy_cache_key "$ scheme: // $ host $ request_uri"

If this setting is incorrect, you cannot the correct filename and the cache will not be able to delete.

This value can also be customized in nginxchampuru_get_reverse_proxy_key filter hook of Nginx Cache Controller inside, but in that case, you will need to modify to match it and to set a reverse proxy site.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk