{eac}Doojigger Simple CDN Extension for WordPress

{eac}Doojigger Simple CDN Extension for WordPress

Wordpress plugin

Install on Wordpress

App Details

{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-2024, 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/.

Pricing

Starting from $0 per month.

Check Out the FAQ Widget

By Common Ninja

FAQTry For Free!

App Info

Rating

Reviewers

No reviews

Tags

caching
cdn
cloudfront
content delivery network
keycdn

Developed By

Kevin Burkholder

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Forms

Forms plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Comments

Comments plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Maps

Maps plugins for Wordpress

Security

Security plugins for Wordpress

Translation

Translation plugins for Wordpress

Ads

Ads plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Chat

Chat plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Membership

Membership plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Contact

Contact plugins for Wordpress

Comments

Comments plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

FAQ for Wordpress logo

FAQ

Add an FAQ section to your site to answer common questions, reduce support requests, and give visitors a smoother and more confident user experience.

Calculator for Wordpress logo

Calculator

Create a TDEE Calculator that helps visitors estimate daily calorie needs and make informed decisions.

Notification Popup for Wordpress logo

Notification Popup

Show alerts and updates with a notification popup that grabs attention, delivers important messages, and improves user experience.

Flip Cards for Wordpress logo

Flip Cards

Use flip cards to present information interactively, improve visual design, and guide visitors toward clearer decisions that support conversions.

Facebook Reviews for Wordpress logo

Facebook Reviews

Show Facebook reviews to build trust, improve credibility, and help visitors make confident purchase decisions that support higher sales.

Capterra Reviews for Wordpress logo

Capterra Reviews

Show Capterra reviews to build trust, strengthen credibility, and help visitors make confident software buying decisions that support higher sales.

Job Application Form for Wordpress logo

Job Application Form

Collect candidate information with a job application form that organizes submissions, streamlines hiring, and helps you manage applicants efficiently.

Scroll to Element Button for Wordpress logo

Scroll to Element Button

Scroll to element button that improves navigation by letting visitors jump directly to key sections, reducing friction and boosting overall engagement.

Image Stack Gallery for Wordpress logo

Image Stack Gallery

Showcase photos with an image stack gallery that layers images in a stacked display with smooth transitions to create a visually striking presentation.

Image Hotspot for Wordpress logo

Image Hotspot

Add interactive image hotspots to your site to turn static visuals into clickable guided experiences that improve engagement.

Before & After Slider for Wordpress logo

Before & After Slider

Add an interactive before and after slider to your site to show visual transformations, capture attention, and help visitors understand real results.

Petition Form for Wordpress logo

Petition Form

Gather supporter signatures with a petition form that collects entries, saves submissions, sends notifications, and helps you drive meaningful change efficiently.

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms