[WordPress] 外掛分享: Cache control by Cacholong

首頁外掛目錄 › Cache control by Cacholong
WordPress 外掛 Cache control by Cacholong 的封面圖片
500+
安裝啟用
尚無評分
1703 天前
最後更新
問題解決
WordPress 4.3.1+ PHP 5.6+ v5.4.1 上架:2018-03-05

內容簡介

>「Cache control by Cacholong」插件可以自動在您的Nginx服務器上清除Nginx Pagespeed快取和Nginx FastCGI快取。這是一個後端插件,能夠:

清除Nginx Pagespeed和/或Nginx FastCGI快取。
可以自動或手動清除快取,使用WordPress cronjobs和WP-CLI。
在一個或多個服務器上清除快取(有關更多詳細信息,請參閱hosts.json部分)。
使用命令行(WP-CLI)清除快取或重置為出廠設置。
從樣式表鏈接標籤中刪除ID標籤,以允許Nginx Pagespeed合併樣式表。
允許清除其他緩存項目(參見“設置” > “快取控制”)。
通知用戶清除狀態。
支持單站點和網絡站點
支持WP-CLI
支持WPML(包括語言協商類型域)

什麼時候會清除快取?

此插件將與默認和自定義文章類型一起工作。它會在保存、定期更新、快速編輯更新、標記更改、刪除和取消刪除時清除。用戶將收到一個或多個消息以進行通知。
有一些注意事項:

當用戶使用Gutenberg編輯器時,清除消息將不會顯示。
當用戶使用“快速編輯”和“更新”修改文章時,不會顯示任何消息,因為沒有頁面刷新。這些消息將顯示在下一個請求中。

可以使用WordPress cronjobs清除快取。調整“Cronjob設置”以執行每天清除快取。

您也可以手動清除項目。轉到WordPress儀表板,導航至:

設置 > 快取控制 > 清除單個項目
設置 > 快取控制 > 清除所有緩存
管理工具列 > 清除所有緩存

設置

主機文件(JSON):文件帶有有關此WordPress安裝的一個或多個主機信息。有關更多詳細信息,請參閱hosts.json部分。
Pagespeed優化CSS:刪除所有WordPress樣式表鏈接標籤中的ID標籤,以改善Nginx Pagespeed緩存。僅適用於前端。
清除設置默認文章類型:在清除默認文章類型時,選擇一個或多個選項。可以清除文章URL(默認)、首頁、所有相關的WordPress分類或所有緩存。
清除設置默認自定義類型(s):在清除自定義文章類型時,選擇一個或多個選項。可以清除文章URL(默認)、首頁、所有相關的WordPress分類或所有緩存。

Cronjob設置

計劃程序清除:啟用或禁用計劃程序清除。
每天的Cronjob時間:輸入24小時符號(HH:MM)以設置每天的Cronjob時間。如果格式錯誤,則會回退到00:00。
清除緩存:選擇要在給定的Cronjob時間清除的緩存。

hosts.json

Hosts.json是一個帶有有關此WordPress安裝的一個或多個服務器信息的JSON文件。請記住,此文件必須包含所有服務器的信息,包括帶有此插件的服務器。默認路徑為:wp-content/uploads/cacholong-cache-control/hosts.json。

以下是一個hosts.json文件的示例:

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

每行都包含有關一個服務器的信息。參數:

名稱(字符串)

外掛標籤

開發者團隊

⬇ 下載最新版 (v5.4.1) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Cache control by Cacholong」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

“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 cache automatically, manually, with WordPress cronjobs and WP-CLI.
Purge caches on one or more servers (See hosts.json section for more details).
Use commandline (WP-CLI) to purge caches or reset to factory settings.
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.
Support for single site and network sites
Support for WP-CLI
Support for WPML (including language negotiation type domain)

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 are a few caveats:

When a user is using the Gutenberg editor, purge messages will not be displayed.
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.

It is possible to purge with WordPress cronjobs. Adjust the ‘Cronjob settings’ to perform a daily purge of caches.
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. Will only work on frontend.
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.

Cronjob Settings

Cronjob purging: Enable or disable cronjob purging.
Cronjob time of each day: Enter HH:MM in 24 hour notation for cronjob time of day. Will fallback to 00:00 when wrong format is given.
Purge caches Select caches to purge on given cronjob time.

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 the
one with this plugin. Default path is: wp-content/uploads/cacholong-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.
WP-CLI
There are several commands available for the commandline with wp-cli. Commands generate text output which can be suppressed with –quiet. When an error occurs, text will always be displayed.
WP-CLI exit codes
Exit codes are 0 (no errors) or 1 (generic error).
WP-CLI examples
Purge command with all arguments:
wp cacholong_cc purge [--cache=] [--ips=]

Purge Nginx FastCGI:
wp cacholong_cc purge --cache=fastcgi

Purge Nginx Pagespeed:
wp cacholong_cc purge --cache=pagespeed

Purge all caches:
wp cacholong_cc purge --cache=all
wp cacholong_cc purge

Purge Nginx Pagespeed cache for ip address 127.0.0.1 and 127.0.0.2:
wp cacholong_cc purge --cache=pagespeed --ips=127.0.0.1,127.0.0.2

Purge all caches for ip address 127.0.0.1 and 127.0.0.2:
wp cacholong_cc purge --ips=127.0.0.1,127.0.0.2

Factory reset options for given site_id or current blog if no site_id is given:
wp cacholong_cc factory_reset [--site_id=site_id]

Debug
Plugin will log basic purge information when WP_DEBUG is true (can be set in wp-config.php). Logs information in file wp-content/cacholong-cache-control.log.
Plugin will log wp_remote_request details when CACHOLONG_CACHE_DEBUG_HTTP_API_REQUEST is true (can be set in wp-config.php). Logs information in file wp-content/cacholong-cache-control.log.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon