[WordPress] 外掛分享: Jinx Fast-Cache

WordPress 外掛 Jinx Fast-Cache 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Jinx Fast-Cache」是 2022-02-09 上架。
  • 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
  • 上一次更新是 2023-12-20,距離現在已有 501 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 5.0 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 8.0 以上。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

lugat |

外掛標籤

html | cache | files | fullpage | pagecache |

內容簡介

Jinx Fast-Cache 提供了一個簡單但有效的全頁面快取方式供 WordPress 使用。
它會生成靜態 HTML 檔案,並且會利用您的伺服器重寫規則來呼叫這些檔案。
透過這個功能,系統可以略過整個 PHP 處理過程,並且只輸出一個簡單的 HTML 檔案,避免不必要的開銷。

使用方法

在啟用外掛之後,它會修改您的 htaccess 檔案。如果這不能被執行,請確認自行輸入以下規則:

# BEGIN Jinx Fast-Cache
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/wp-content/jinx-fast-cache/%{HTTP_HOST}/%{REQUEST_URI}/%{QUERY_STRING}/index.html -s
RewriteCond %{REQUEST_METHOD} GET
RewriteRule .* /wp-content/jinx-fast-cache/%{HTTP_HOST}/%{REQUEST_URI}/%{QUERY_STRING}/index.html [L]
# END Jinx Fast-Cache

如果使用 nginx,請確認加入以下規則:

set $cache_path false;
if ($request_method = GET) {
set $cache_path /wp-content/jinx-fast-cache/$host/$uri/$args/index.html;
}
location / {
try_files $cache_path $uri $uri/ /index.php?$query_string;
}

您可以透過管理列的按鈕,對單一或多個 URL 進行快取清空、預先加載或更新 (清空並預先加載)。

預設情況下,每當文章完成儲存,所有文章會自動預先加載,而在文章被刪除或變成草稿之後,就會自動清空快取。

進行預先加載時,系統會建立一個工作清單,並在定期工作 (cron) 中處理。當預先加載單篇文章時,它會跳過工作清單。

插件會在完成更新之後自動清空快取,並且預先加載快取。

開發人員
篩選器

Jinx Fast-Cache 非常適合開發人員使用。目前並無後台面板可供使用,但您可以透過篩選器修改許多功能行為。

jinx_fast_cache:回傳 true(預設值)或 false,以控制是否快取該 URL。
jinx_fast_cache_post_types: 控制應該快取的文章類型。預設情況下,快取所有「可供公開查詢」和「頁面」的文章類型。
jinx_fast_cache_posts: 篩選應該快取的文章。
jinx_fast_cache_taxonomies: 控制應該快取的分類法。預設情況下,快取所有「可供公開查詢」的分類法。
jinx_fast_cache_terms: 篩選應該快取的關聯詞。
jinx_fast_cache_output: 改寫 HTML 內容以使用快取檔案。
jinx_fast_cache_minify: 回傳 true(預設值)或 false,以指定是否將輸出進行最小化。
jinx_fast_cache_flush: 控制應該清除的 URL。此功能可用於清空相關 URL,例如您的首頁。
jinx_fast_cache_warm: 控制應該預先加載的 URL。此功能可用於預先加載相關 URL,例如您的首頁。
jinx_fast_cache_interval: 變更排程工作時間間隔 (預設為 60)。
jinx_fast_cache_queue_size: 變更在執行排程工作期間會處理的 URL 數目 (預設為 10)。當設為小於或等於 0 時,將處理所有 URL。這可能會造成大量負載,尤其是當您的網站有很多 URL 時。

插入

Jinx Fast-Cache 還提供了插入動態內容的功能。例如,如果您要在頁面上列印使用者姓名,您可以通過 AJAX 進行插入。

請注意,第一個參數是占位符內容。透過這個方法,當不使用外掛時,就不會發生任何問題。您可以正常載入模板,或是顯示像「正在載入」之類的提示文字。

插入模板:

do_action('jinx_fast_cache_inject_template', 'user');

原文外掛簡介

Jinx Fast-Cache provides a very simple but efficient way of full page caching to WordPress.
It will generate static HTML files which will be called using your servers rewrite rules.
This feature will bypass the whole PHP process and render only a simple HTML file without the whole overhead.
Usage
After activating the plugin, it will modify your .htaccess file. If this is not possible, make sure to enter the rules by yourself:
# BEGIN Jinx Fast-Cache
RewriteEngine On
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/wp-content/jinx-fast-cache/%{HTTP_HOST}/%{REQUEST_URI}/%{QUERY_STRING}/index.html -s
RewriteCond %{REQUEST_METHOD} GET
RewriteRule .* /wp-content/jinx-fast-cache/%{HTTP_HOST}/%{REQUEST_URI}/%{QUERY_STRING}/index.html [L]
# END Jinx Fast-Cache

When using nginx, make sure to add the following rules:
set $cache_path false;
if ($request_method = GET) {
set $cache_path /wp-content/jinx-fast-cache/$host/$uri/$args/index.html;
}
location / {
try_files $cache_path $uri $uri/ /index.php?$query_string;
}

You may flush, warm or refresh (flush & warm) single or multiple URLs using the buttons in the admin bar.
By default all posts will be automatically warmed after they have been saved and flushed after they have been deleted or put on draft.
The warm process will create a queue, which will be handled in a scheduled task (cron). When warming up a single post, it will skip the queue.
The plugin will automatically flush and warm the cache after an update has been completed.
Developers
Filters
Jinx Fast-Cache is made for developers. So far no admin panel is available, but you may modify a lot of it’s behaviors using filters.

jinx_fast_cache_active: Control if an URL should be cached (default true) or not.
jinx_fast_cache_post_types: Control the post types which should be cached. By default all post types which are “publicly_queryable” and “page” will be cached.
jinx_fast_cache_posts: Filter the posts which should be cached.
jinx_fast_cache_taxonomies: Control the taxonomies which should be cached. By default all taxonomies which are “publicly_queryable” will be cached.
jinx_fast_cache_terms: Filter the terms which should be cached.
jinx_fast_cache_output: Use this to modify the HTML content written to your cache file.
jinx_fast_cache_minify: Control if the output should be minified (default true) or not.
jinx_fast_cache_flush: Control which URLs should be flushed. This may be used to flush related URLs eg. your front page.
jinx_fast_cache_warm: Control which URLs should be warmed. This may be used to warm related URLs eg. your front page.
jinx_fast_cache_queue_interval: Change the interval of the queues cron task (default 60) to warm URLs.
jinx_fast_cache_queue_size: Change the number of URLs which should be handled durring a cron task (default 10). When setting it to {
// so smth. with e.target
}, false);

Tags

Even there are some filters to build a relation between URLs, tags are an easier way to do this.
You may connect multiple URLs with tags, so if one URL gets flushed, it will also flush URLs with the same tag.
Tags can be used inside the editor by using the shortcode:
[jinx_fast_cache tags="foo,bar"]

Or you can use it inside your templates by calling the action:
do_action('jinx_fast_cache', ['tags' => 'foo,bar']);
do_action('jinx_fast_cache', ['tags' => ['foo', 'bar']]);

A usecase for tags might be to connect single posts with your page for posts. So if a single post will be flushed, the page for posts and all other posts will also be flushed.
You may also add multiple tags by calling the shortcode or action multiple times. This will work very well when using blocks or other shortcodes.
Cache duration
As you have seen already, you may set a cache duration globally by using the filter ‘jinx_fast_cache_duration’.
However, if there is a specific URL eg. the front page, you may want to change the duration.
You may use a shortcode like this:
[jinx_fast_cache duration="3600"]
[jinx_fast_cache duration="12 hours"]

Or you can use it inside your templates by calling the action:
do_action('jinx_fast_cache', ['duration' => 3600]);

Hits

Be aware that you can set tags and the cache duration in just one call.
[jinx_fast_cache duration="3600" tags="foo,bar"]

Or you can use it inside your templates by calling the action:
do_action('jinx_fast_cache', ['duration' => 3600, 'tags' => 'foo,bar']);
do_action('jinx_fast_cache', ['duration' => 3600, 'tags' => ['foo', 'bar']]);

Note that tags will accept a string or an array.
Roadmap

[x] Release the plugin
[x] Add HTML minification for output
[x] Allow injection of dynamic rendered templates using ajax requests
[x] Add taxonomies
[x] Provide scheduled tasks
[x] Add admin columns for cache status
[x] Provide exclude option for posts and terms in backend
[x] Add multisite support
[x] Flush and warm after update complete
[x] Add possibility to ignore 404
[x] Allow query params to be excluded or totally ignored
[x] Provide cache duration
[ ] Provide admin panel to change options
[x] Add tags to flush related pages
[x] Add shortcode for injects
[x] Add JS events for injects

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Jinx Fast-Cache」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


最新版本

延伸相關外掛(你可能也想知道)

  • File Manager Pro – Filester 》Filester 是 WP File Manager Pro 插件,但你可以完全免費下載和使用。它具有其他 WordPress 高級文件管理插件的所有高級功能。, , Filester 幫助您管理 Word...。
  • Media Cleaner: Clean your WordPress! 》Media Cleaner 是一個強大的外掛,它可以幫助你清理 WordPress 媒體庫中未使用的媒體條目和文件,以及修復損壞的條目。內置回收站功能讓你可以在永久刪除之前...。
  • Clean Image Filenames 》這個外掛可以在您上傳至媒體庫時自動將檔名中的語言重音符號轉換。轉換後的字符將會變成網頁和伺服器友好、無語言重音的字元。, 功能, , 將瑞典語、丹麥語、...。
  • File Upload Types by WPForms 》WordPress 檔案上傳類型外掛, 您是否希望您的 WordPress 網站接受更多類型、更自由地上傳檔案?我們創建了『File Upload Types』外掛,讓任何人都可以輕鬆地...。
  • Media from FTP 》從透過 FTP 上傳的檔案註冊到媒體庫, , 此外採取縮略圖的方式, 此外創建圖片、影片、音訊的元數據, 修改日期/時間, 使用 DateTimePicker jQuery 外掛程式進行...。
  • Download Attachments 》Download Attachments 是 WordPress 的新型下載管理工具,它可以簡化界面、提供拖放和 AJAX 驅動的 metabox 來插入和管理您的媒體庫文件,然後通過自動或手動...。
  • File Away 》從您的伺服器目錄或頁面附件上傳、管理和顯示檔案,以時尚的清單或可排序的資料表方式呈現,還有更多更多的功能。。
  • Bulk Media Register 》在伺服器上批次註冊檔案至媒體庫。, 註冊至媒體庫, , 維持資料夾結構。, 製作圖片檔案縮圖。, 建立影音檔案的元數據。, 更改日期/時間。, , 類似外掛, , Movi...。
  • Custom Upload Dir 》WordPress 允許您將上傳文件放置在以年和月為基礎的文件夾中。Custom Upload Dir 會更具靈活性,您可以從變數(如文章標題、分類、作者、發布日期及許多其他...。
  • WP Users Media 》WP User Media 外掛啟用時即可立即使用,不需要進行其他設定。如果您需要開啟管理者的選項,可以在設定區域中的選項頁面中處理。, 該外掛的功能是禁止使用者...。
  • WP-DownloadManager 》一般使用, , 您需要重新生成永久鏈接WP-Admin -> 設置 -> 永久鏈接 -> 儲存變更, 為了將一個特定的檔案嵌入文章/頁面中以供下載,請使用[download i...。
  • WP Synchro – WordPress Migration Plugin for Database & Files 》專為 WP 專業人士打造的完整遷移插件, 作為專業的 WordPress 開發人員,您只需要這個遷移工具。, WP Synchro 的設計是為開發人員製作的遷移插件,可進行自定...。
  • Media File Sizes 》這個外掛會在媒體庫頁面上增加一欄,顯示每個媒體項目所使用的總空間。對於圖像來說,這包括原始圖像以及生成的任何其他大小。, 這個外掛對于有限空間配額的...。
  • BuddyDrive 》作為 BuddyPress 的外掛程式,BuddyDrive 允許社群成員輕鬆分享文件或文件夾。透過 BP 附件 API,BuddyPress 使分享內容成為可能,包括:, , 僅擁有者(私人...。
  • Upload Media By URL 》這個外掛讓您能夠透過 URL 上傳檔案至 WordPress 媒體庫。, 已知問題, 這個外掛可能會與改變 WordPress 媒體庫頁面的任何其他外掛發生衝突。, 如果 URL 包含...。

文章
Filter
Apply Filters
Mastodon