[WordPress] 外掛分享: Queue Ajax Calls Performantly

首頁外掛目錄 › Queue Ajax Calls Performantly
全新外掛
安裝啟用
尚無評分
353 天前
最後更新
問題解決
WordPress 5.8+ PHP 7.4+ v1.1.3 上架:2025-04-06

內容簡介

總結:這個外掛提供了一種將 Ajax 呼叫排入隊列的方式,可以跳過 WP 系統載入的大部分,節省系統資源如CPU負載和執行時間。這個操作可以應用到任何 Ajax 呼叫。這是透過一個 MU 外掛在 WP 周期早期捕捉 Ajax 呼叫完成的,這些呼叫經過消毒(使用者需要定義欄位),並存儲在隊列中以便以後處理。隊列系統基於 Automattic 自己的 Action Scheduler 外掛。

問題與答案:
1. 這個外掛的主要功能是什麼?
- 提供了一種將 Ajax 呼叫排入隊列的方式,可以跳過 WP 系統載入的大部分,節省系統資源如CPU負載和執行時間。
2. 這外掛的操作流程是什麼?
- 透過一個 MU 外掛在 WP 周期早期捕捉 Ajax 呼叫完成的,並對其進行消毒,然後存儲在DB中以便批量處理,最後通過 CRON 接口批量處理這些呼叫。
3. 這外掛適合哪些使用者?
- 此外掛目前僅針對開發人員級別設計,需要定義消毒字段,但對於大多數情況,可使用基本實現最新 PixelYourSite API 呼叫的功能。

這些問題與答案可以用以下 HTML 編碼的無序列表呈現:
<ul>
<li>這個外掛的主要功能是什麼?</li>
<ul>
<li>提供了一種將 Ajax 呼叫排入隊列的方式,可以跳過 WP 系統載入的大部分,節省系統資源如CPU負載和執行時間。</li>
</ul>
<li>這外掛的操作流程是什麼?</li>
<ul>
<li>透過一個 MU 外掛在 WP 周期早期捕捉 Ajax 呼叫完成的,並對其進行消毒,然後存儲在DB中以便批量處理,最後通過 CRON 接口批量處理這些呼叫。</li>
</ul>
<li>這外掛適合哪些使用者?</li>
<ul>
<li>此外掛目前僅針對開發人員級別設計,需要定義消毒字段,但對於大多數情況,可使用基本實現最新 PixelYourSite API 呼叫的功能。</li>
</ul>
</ul>

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.1.3) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Queue Ajax Calls Performantly」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

This plugin offers a way to queue Ajax calls, skipping the loading of the the bulk of WP system, saving considerable system resources in the form of CPU load and runtimes. This operation can be set for any AJAX call.
This is done by catching the AJAX calls early in the WP lifecycle, via an MU plugin. The calls are santized ( user should define fields ) and ar stored in a queue for later processing. The queue system is based on Automattic’s own Action Scheduler plugin.
Processing the calls : the calls are processed in bulk via a hook that is run by CRON.
The original motivation for this development was to handle the multitudes AJAX calls that the PixelYourSite evokes when the facebook conversation API is in use. The conversation API requires the server to send the tracking information instead of the client browser. This means possibly lots of calls even if the site is beyond walls of cache.
Who is it for
At this stage the plugin is a developer level plugin and is intended to be used as such. It requires defining fields for sanitation.
However, it comes with a basic implementation for the latest PixelYourSite API calls and can be easily activated without further configuration for most cases.
The flow

AJAX call evoked in the client browser ->
MU plugin catches the call if the configuration includes the specific action of the call ->
Processor ( built-in or user defined ) checks the data and sanitizes it ->
Data is stored in DB to be handled in queue. The data includes the call’s data and cookies ->
Data is processed in batch via a CRON hook. The processing is done via the same “Processor”.

Basic terminogoly
Processor : A class/instance that is used to define the data map of fields for sanitation and later on, for batch processing. In many cases, the Processor will be quite simple. Please check the built-in Processor class “class-pys.php” under the “qacp/Processors” directory.
Data Map : The map of fields and their respectable sanitation functions. There’s an example in the “qacp/qacp-how-to.txt” file.
Things to Remember

The Processor should define clearly what are the received fields and their sanitation functions.
The action and processor should be registerd. There’s an example in the “qacp/qacp-how-to.txt” file.

Hooks

qacp/processors/active_processors
qacp/processors/actions
qacp/processors/identify_processor

qacp/processors/instance_by_action_name

qacp_before_batch_processing

qacp_before_process_entry_{$_action_name}
qacp_before_process_entry
qacp_process_one_entry_{$_action_name}
qacp_process_one_entry
qacp_mark_event_finished
qacp_after_process_entry_{$_action_name
qacp_after_process_entry
qacp_after_batch_processing

延伸相關外掛

文章
Filter
Apply Filters
Mastodon