[WordPress] 外掛分享: {eac}Doojigger Simple CDN Extension for WordPress

WordPress 外掛 {eac}Doojigger Simple CDN Extension for WordPress 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「{eac}Doojigger Simple CDN Extension for WordPress」是 2023-09-20 上架。
  • 目前尚無安裝啟用數,是個很新的外掛。如有要安裝使用,建議多測試確保功能沒問題!
  • 上一次更新是 2025-04-30,距離現在已有 5 天。
  • 外掛最低要求 WordPress 5.8 以上版本才可以安裝。
  • 外掛要求網站主機運作至少需要 PHP 版本 7.4 以上。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

kevinburkholder |

外掛標籤

cdn | keycdn | caching | cloudfront | content delivery network |

內容簡介

- SimpleCDN是一個Doojigger擴展,可以在您的網站前端頁面上重寫URL,從而從您的內容分發網絡(CDN)而不是從您的WordPress服務器加載特定內容。
- CDN(內容分發網絡)是一個地理分佈式的代理伺服器和數據中心網絡。其目標是通過與終端用戶的相對空間分佈提供高可用性和性能。
- SimpleCDN不是一個內容分發網絡(CDN),它的功能是過濾您的網頁,用CDN的地址替換本地http地址,從而使您的站點資源(圖片、腳本等)從CDN而不是直接從您的Web服務器加載。
- 您可以指定哪些文件類型應該從CDN加載,并添加url字符串排除以防止特定url從CDN加載。
- SimpleCDN與Amazon CloudFront、KeyCDN、Akamai ION、RocketCDN、StackPath、Rackspace、Azure CDN以及許多其他內容分發網絡和許多雲存儲服務(如Amazon S3或Google Cloud Storage)兼容。
- 如果您使用CloudFront並啟用了SimpleAWS擴展,您可以通過提供您的CloudFront發佈ID來清除CDN緩存(使發佈無效)。
- 如果您使用其他受支援的CDN,您可以通過提供特定於您使用的CDN的API憑證來清除CDN緩存。
- 對於不支持的或通用的CDN,只要CDN能夠將所有可緩存的站點內容存儲在與您的Web服務器相匹配的目錄結構中,SimpleCDN也可以很好地運行。唯一的不同之處在於尚未實現清除CDN緩存的API。
- 如果CDN服務不會自動從您的原始服務器檢索文件,您需要從您的Web服務器上傳所有可緩存的文件到CDN存儲中,或使用其他方法同步文件。
- 額外選項包括:將其他域名視為本地域名(在多站點和/或CDN具有多個起源時很有用),可緩存的下載(將其他文件類型重寫為CDN主機),頁面包含(基於頁面URI中的字符串只包含特定頁面URI),URL包含(僅使用URL中的字符串來限制頁面上被重寫的URL)。
- 在多站點伺服器上,當SimpleCDN啟用網絡時,網絡管理員可以將設置推送到所有個別網站上。個別網站管理員可以從網絡管理員處提取設置。
- 提供的可用方法有:flush_cdn_cache()(如果支持,告訴SimpleCDN刷新CDN緩存)。
- 提供的可用過濾器有:SimpleCDN_page_enabled(啟用/禁用對當前頁面的CDN使用)、SimpleCDN_file_types(包含文件類型的字符串,使用“|”分隔)、SimpleCDN_include_strings(包含要包含的字符串的字符串,使用“|”分隔)、SimpleCDN_exclude_strings(包含要排除的字符串的字符串,使用“|”分隔)。
- 提供的可用操作有:SimpleCDN_flush_cache(告訴SimpleCDN刷新CDN緩存,如果支持)和SimpleCDN_cache_flushed(SimpleCDN刷新了CDN緩存時觸發)。
- 通用CDN是SimpleCDN不完全支持的CDN,並且被視為通用處理。不包括其他選項,也不包括清除CDN緩存的API。您可以通過自定義代碼和以下過濾器添加額外選項和清除功能。
- 提供的通用CDN方法有:SimpleCDN_add_settings(在設置頁面上添加額外選項字段)、SimpleCDN_add_help(添加附加語境幫助)、SimpleCDN_purge_cdn_cache(添加支援和自定義方法來清除(清空)CDN緩存)。

原文外掛簡介

{eac}SimpleCDN is an {eac}Doojigger extension which rewrites the URLs on your site’s front-end pages so that specific content is loaded from your Content Delivery Network rather than your WordPress server.

What is a CDN?
A content delivery network, or content distribution network, is a geographically distributed network of proxy servers and their data centers. The goal is to provide high availability and performance by distributing the service spatially relative to end users. Wikipedia

{eac}SimpleCDN is not a content delivery network. What it does is filter your web pages replacing local http addresses with the address of your CDN so that your site assets (images, scripts, etc.) are served from your CDN rather than directly from your web server.
You can specify what file types should be served from the CDN and add url string exclusions to prevent specific urls from being served from the CDN.
{eac}SimpleCDN works with Amazon CloudFront, KeyCDN, Akamai ION, RocketCDN, StackPath, Rackspace, Azure CDN
and many other Content Delivery Networks as well as many cloud storage services such as Amazon S3 or Google Cloud Storage.
If you’re using CloudFront and you have the {eac}SimpleAWS extension enabled, you can flush the CDN cache (invalidate the distribution) by providing your CloudFront distribution id.
If you’re using any other supported CDN, you can flush the CDN cache by providing your API credentials specific to the CDN you’re using.
Unsupported, or Universal CDNs will work just as well with {eac}SimpleCDN provided that the CDN will store and serve all cacheable site content in a directory structure matching your web server. The only difference is that the API to purge the CDN cache has not been implemented (yet).
If the CDN service does not automatically retrieve files from your origin server, you will need to upload all cacheable files from your web server to the CDN storage or use some other method to synchronize your files.
Extra Options
The extra options include:

Additional Domains treated as local domain(s), useful with multi-site and/or when your CDN has multiple origins.
Cacheable Downloads additional file type(s) to be rewitten with the CDN host.
Page Inclusions to only include specific page URIs based on string(s) in the URI.
URL Inclusions to limit URLs on the page to be rewritten by string(s) in the URL.

To enable the extra options, first enable the SimpleCDN Menu option, then select Enable Extra Options from the SimpleCDN menu.
Network/Multisite
On a multi-site server, when {eac}SimpleCDN is network enabled, the network administrator has the option to push settings to all individual sites. The individual site administrators have the option to pull settings from the network administrator.
Available Methods
flush_cdn_cache() tells {eac}SimpleCDN to flush the cdn cache (if supported).

Available Filters
SimpleCDN_page_enabled enable/disable use of cdn on current page.

SimpleCDN_file_types filter string of included file types (delimited by '|').

SimpleCDN_include_strings filter string of included strings (delimited by '|').

SimpleCDN_exclude_strings filter string of excluded strings (delimited by '|').

Available Actions
SimpleCDN_flush_cache tells SimpleCDN to flush the cdn cache (if supported).

SimpleCDN_cache_flushed triggered when SimpleCDN has flushed the cdn cache.

Universal CDNs
A Universal CDN is a CDN not fully supported by {eac}SimpleCDN and is treated universally. No additional options, no purge API is included.
With your custom code and the following filters, additional options and purging may be added.
SimpleCDN_add_settings add additional option fields to the settings page.

SimpleCDN_add_help add additional contextual help.

SimpleCDN_purge_cdn_cache adds support for and custom method to flush (purge) the CDN cache.

This is a special-use case for Universal CDNs where custom code can be added to both indicate that the cache can be purged and to provide the method for doing the purge. When this hook has an action, the “Purge” button and menu items are automatically added. The hook should be added on or before the admin_init action.
See the examples for more detail.
HTTP Headers
An http request may include a header to disable the CDN…
x-Simple-CDN: off

{eac}SimpleCDN includes an http response header…
x-Simple-CDN: on

Important Notes

Time To First Byte (TTFB) may be slightly longer. Your pages are not being served by your CDN and {eac}SimpleCDN captures and buffers the page, then rewrites the asset URLs in the page, before any content is delivered to the browser. Although {eac}SimpleCDN endevores to do this as quickly and efficiently as possible, doing it takes a little more time than not doing it.

Load time may be deceiving. For example, my business network and my web server are in the same zone as the closest CDN edge server (maybe in the same datacenter). Checking load times with and without the CDN from my location produces negligible difference. However, the CDN produces significant load time reduction in more distant zones.

Results
You can test your results here: PageSpeed Insights

Examples
All CDNs
// disable CDN use
\add_filter('SimpleCDN_page_enabled','__return_false');

// flush the cdn cache (if supported)
\do_action('SimpleCDN_flush_cache');
// or...
if ($cdn = $this->getExtension('Simple_CDN')) {
$cdn->flush_cdn_cache();
}

// do action whenever the cdn cache is flushed
\add_action('SimpleCDN_cache_flushed', 'my_cdn_flushed', 10, 2);

/**
* After purging the CDN cache
*
* @param object $cdn provider object
* object $cdn->parent the SimpleCDN class object
* string $cdn->endpoint e.g. c2nnnn.r10.cf1.rackcdn.com/path
* string $cdn->hostname e.g. c2nnnn.r10.cf1.rackcdn.com
* string $cdn->bucket e.g. c2nnnn
* string $cdn->host e.g. r10.cf1.rackcdn.com
* string $cdn->domain e.g. rackcdn.com
* string $cdn->provider e.g. Rackspace
* @param string|bool $context context ('purge_button'|'purge_menu') or false (non-interactive)
*/
function my_cdn_flushed($cdn,$context)
{
$cdn->admin_success($context,"Success: The CDN purge is in progress");
}

// limit the file types being cached by the CDN
\add_filter('SimpleCDN_file_types', function($types)
{
return '.css|.jpeg|.jpg|.js|.png|.webp';
}
);

// add plugins folder to excluded strings
\add_filter('SimpleCDN_exclude_strings', function($exclude)
{
return $exclude . '|/plugins/';
}
);

Universal CDNs
// add additional settings fields
\add_filter( 'SimpleCDN_add_settings', 'my_add_cdn_fields', 10, 2 );

/**
* Add custom options/settings
*
* @param array $options array()
* @param object $cdn provider object
* object $cdn->parent the SimpleCDN class object
* string $cdn->endpoint e.g. c2nnnn.r10.cf1.rackcdn.com/path
* string $cdn->hostname e.g. c2nnnn.r10.cf1.rackcdn.com
* string $cdn->bucket e.g. c2nnnn
* string $cdn->host e.g. r10.cf1.rackcdn.com
* string $cdn->domain e.g. rackcdn.com
* string $cdn->provider e.g. Rackspace
*/
function my_add_cdn_fields($options,$cdn)
{
$options['simple_cdn_universal_key'] = array(
'type' => 'text',
'label' => 'API Key',
'info' => 'Your '.$cdn->provider.' API key',
);
return $options;
}

// add custom code to flush/purge the CDN
\add_action( 'admin_init', function()
{
\add_action( 'SimpleCDN_purge_cdn_cache', 'my_purge_cdn_cache', 10, 2 );
});

/**
* Purge the CDN cache (custom)
*
* @param object $cdn provider object
* object $cdn->parent the SimpleCDN class object
* string $cdn->endpoint e.g. c2nnnn.r10.cf1.rackcdn.com/path
* string $cdn->hostname e.g. c2nnnn.r10.cf1.rackcdn.com
* string $cdn->bucket e.g. c2nnnn
* string $cdn->host e.g. r10.cf1.rackcdn.com
* string $cdn->domain e.g. rackcdn.com
* string $cdn->provider e.g. Rackspace
* @param string|bool $context context ('purge_button'|'purge_menu') or false (non-interactive)
*/
function my_purge_cdn_cache($cdn,$context)
{
if ($apiKey = $cdn->get_option('simple_cdn_universal_key'))
{
/* code to purge the cdn cache */
}

if (/* error condition */)
{
$cdn->admin_error($context,"Error: status {$status}, " . $message);
}
else
{
$cdn->admin_success($context,"Success: The CDN purge is in progress");
}
}= Additional Information =

{eac}SimpleCDN is an extension plugin to and requires installation and registration of {eac}Doojigger.

Copyright
Copyright © 2023-2025, EarthAsylum Consulting, distributed under the terms of the GNU GPL.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should receive a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

各版本下載點

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

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


1.1.1 | 1.1.2 | 1.1.3 | 1.1.4 | 1.1.5 | 1.1.7 | 1.1.8 | 1.1.9 | trunk |

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

暫無相關外掛推薦。

文章
Filter
Mastodon