How to set up Cloudflare APO for WordPress-improve performance by up to 300%

For performance enthusiasts, Cloudflare’s APO represents a big step forward in maximizing WordPress performance.

in our benchmark, we found that enabling APO on our test site reduced page load time by 70-300%, depending on the test location.

in this article, we will delve into how Cloudflare APO works and how to use it to improve the performance of WordPress sites!

  1. what is automatic platform Optimization (APO)?
  2. Edge static HTML
  3. 2022 Web performance
  4. Cloudflare automatic platform Optimization how does
  5. use high-performance hosting and Cloudflare APO to maximize WordPress performance
  6. how to optimize WordPress using Cloudflare automatic platform
  7. how to confirm that Cloudflare APO for WordPress is working
  8. automatic platform Optimization without Cloudflare plug-ins

Automatic Platform Optimization (hereinafter referred to as APO) is a new one-click platform customization and optimization service provided by Cloudflare. The first platform for

to accept “APO treatment” was WordPress, the most popular CMS in the world, with a market share of more than 60 per cent. In the future, we would like to see similar APO services applicable to other CMS and platforms.

at a higher level, Cloudflare’s WordPress APO improves website performance in two main ways. Static HTML copies of

WordPress site pages are cached in Cloudflare Edge servers around the world.

  1. third-party fonts are cached and provided by Cloudflare.
  2. gives us an in-depth look at how and why APO works at the technical level. The key difference between static HTML

Cloudflare’s APO at the edge of

and other traditional page caching and CDN solutions is that it caches static HTML directly at the edge of Cloudflare. To paint a clearer picture, let’s go through four different WordPress settings from “no optimization” to APO.

WordPress setting # 1-No page caching or CDN

by default, WordPress does not provide page caching or CDN support. With this configuration, all requests need to be generated dynamically by PHP, even if the page content is not changed between requests.

in addition, the absence of content delivery Network (CDN) integration means that all static assets, such as CSS, JS, images, and fonts, are served by the source server. This configuration of

can make WordPress sites very slow, especially for visitors away from the source server.

WordPress setting # 2-Page caching without CDN

implementing page caching is one of the best strategies to improve WordPress performance. On some WordPress managed servers, the managed stack includes a highly tuned page cache layer, supported by Nginx’s FastCGI caching module.

page caching greatly reduces the CPU load on the source server because requests can be provided from the cache without generating dynamic HTML.

this frees up your CPU to focus on other important dynamic tasks and makes your WordPress site more stable. Although this configuration may allow your site to process more requests per second, it does not solve the “distance problem”. If

How to set up Cloudflare APO for WordPress-improve performance by up to 300%1

does not have the right CDN, it is still a problem to provide static assets to distant visitors.

WordPress setup # 3-use CDN for page caching

by far, adding a page cache for CDN that provides static assets is by far the most efficient way to host WordPress sites.

in this model, the source server is still responsible for providing the actual HTML for the page. However, static assets such as CSS files, images, and fonts are unloaded to various CDN PoP around the world. The idea behind this model is that static assets, especially large images, make up most of the request page size. therefore, load time can be reduced and performance can be improved by offloading assets to servers closer to visitors.

uses CDN’s Global Traffic routing

How to set up Cloudflare APO for WordPress-improve performance by up to 300%2

although this configuration provides a significant improvement over the previous two configurations it does make you wonder what happens if WordPress performance is no longer a bottleneck because you have to provide HTML from the source server. What’s surprising about

is that before the introduction of Cloudflare’s APO for WordPress, such a setting was not feasible– at least for non-technical users.

WordPress setup # 4-Cloudflare APO

Cloudflare APO for WordPress is the latest WordPress performance optimization solution in the world. Unlike the previous WordPress settings, which were limited by the performance of the origin server, APO-enabled sites are basically “passive” from the visitor’s point of view.

Use Cloudflare APO for global traffic routing

How to set up Cloudflare APO for WordPress-improve performance by up to 300%3

to this end, Cloudflare uses its globally distributed CDN and Workers/Workers KV to create a static HTML representation of your WordPress site. We’ll take a closer look at how Cloudflare APO works later in this article.

now, as long as you know that compatible WordPress sites with APO enabled are no longer subject to delays caused by the source. In other words, requests from visitors from the United States, Germany, and Japan will be served by nearby data centers rather than your source server.

2022 Web performance

in the past few years, the professional Web development industry has undergone great changes. More and more developers are moving from monolithic architectures such as WordPress to more flexible and high-performance static site generators such as Hugo and JavaScript frameworks such as Gatsby.

We use the word “performance” wisely because Web performance can often be interpreted as a subjective metric.

for example, the load time of a page may fluctuate depending on the test location and the time of day.

therefore, it doesn’t make any sense to say that Gatsby static sites are faster than WordPress sites until some context of argument is established.

in today’s highly connected world, one of the most important environments for Web performance testing is the load time in different parts of the world.

this is where static websites outperform WordPress in terms of performance. By default, static sites can be uploaded directly to the globally distributed CDN–, which allows them to spread quickly around the world without any extra work.

cannot directly leverage platforms such as Netlify, Vercel, and Cloudflare’s own Workers Sites for frictionless global delivery because WordPress sites require some type of source server to generate HTML. From a business perspective, this means that you may lose potential visitors and customers away from the original server, because Google takes page speed into account when generating search results.

this is where Cloudflare’s WordPress APO comes into play.

enables Cloudflare APO to improve WordPress performance by 300%

How to set up Cloudflare APO for WordPress-improve performance by up to 300%4

Cloudflare’s WordPress automatic platform optimization is a complete rethink of what WordPress performance means in 2022.

as we mentioned earlier, enabling APO on our test site reduces load time from 70% to 300%, depending on the test location. This is possible because APO effectively eliminates the source server as a performance bottleneck. HowCloudflare’s automatic platform optimization works

uses Cloudflare APO, and your WordPress site’s HTML cache is stored in Cloudflare’s global edge server. This can be achieved through Workers KV, a distributed key-value database service with ultra-fast global propagation (less than 60 seconds).

when data is written to Workers KV through Cloudflare API, it is automatically replicated to more than 150 Cloudflare data centers around the world in a matter of seconds.

this makes Workers KV a leading candidate for accelerated WordPress sites, because articles and pages can easily be represented by key-value mechanisms-URL is a “key” and HTML page content is a “value”.

Web pages stored as key objects in Cloudflare Workers KV

How to set up Cloudflare APO for WordPress-improve performance by up to 300%5

enables APO for your WordPress site, most requests to your site will no longer access your source server.

instead, the request is provided from the local Cloudflare CDN cache (if the cached page exists) or Workers KV (if the cached page does not exist on the CDN of the Cloudflare).

if no page exists in the CDN cache or Workers KV database, Cloudflare makes a single request to your source server and caches the HTML of the new page. The magic of

here is that Cloudflare Workers KV acts as some kind of distributed mirror of your source server. Recall that data stored in Workers KV is automatically replicated throughout the server network of Cloudflare.

this means that even if the source server on which you are running WordPress is located somewhere in the United States, requests from visitors from Japan do not need to access your source server to start the local CDN cache zone.

instead, visitors from Japan will get a cached HTML from a Workers KV database or CDN cache from a nearby Cloudflare data center. The new delivery model of

is very different from previous attempts to cache HTML pages for WordPress. Before

, the most popular method of “full page caching” involved creating Cloudflare page rules to “cache everything.” While this approach can significantly improve performance it is not a very effective caching method because it relies on the pull model rather than Workers KV’s push model which automatically pushes HTML around the world. With

‘s rule-based settings on the previous page, visitors to the US Cloudflare cache do not cache assets for visitors from other locations-which means that websites cannot effectively take advantage of Cloudflare’s network from a global content delivery point of view.

automatic platform optimization takes it a step further by caching third-party fonts. In many cases, fonts end up taking up a large portion of the page’s request size. Unlike CSS, JS, and images that are typically provided from the root domain,

usually comes from third-party services such as Google Fonts. This means that proxy-based caching services such as Cloudflare cannot cache and provide fonts.

because APO is supported by Cloudflare Worker, a programmable JavaScript service worker located between the source server and visitors, additional logic can be injected to accomplish tasks outside the basic cache.

in this case, APO uses Cloudflare Worker to cache third-party fonts and uses inline CSS to modify the page’s HTML to point to cached fonts on Cloudflare CDN. This eliminates the need for additional external requests to obtain fonts and reduces the number of connections and load time required to serve the page.

Finally, because APO integrates with your site through the WordPress plug-in, the Cloudflare cache is automatically cleared whenever you update a page on the site. This ensures that visitors can always see the latest version of your site without any human intervention.

uses high-performance hosting and Cloudflare APO to maximize WordPress performance

however, Cloudflare APO is not a panacea.

‘s choice of a performance-centric WordPress host is still important forfor two main reasons.Cloudflare APO caches only the front-end pages of users who are not logged in. Similar to the server-level page caching configuration, APO does not cache pages with specific cookie and logged-in users.

  1. this means that raw server performance is still a key part of the equation.‘s excellent WordPress experience includes more than just fast front-end performance.
  2. because WordPress is essentially a dynamic CMS, there are many factors to consider when running a WordPress website.here are four use cases that show why you should choose a high-performance WordPress host even if you use Cloudflare APO.

1. WooCommerce, Easy Digital Downloads, and e-commerce

when certain e-commerce-related cookie is detected, Cloudflare APO selectively bypasses the cache. For example, when a visitor adds an item to a shopping cart on a WooCommerce site, WordPress automatically sets the

cookie. When this cookie is detected, APO bypasses the cache to avoid caching and provide customer-specific data. Therefore, even with automatic platform optimization enabled, WooCommerce and other WordPress-based e-commerce platforms will still rely heavily on the performance of the original server.woocommerce_items_in_cart2. WordPress dashboard performance

because Cloudflare APO does not cache HTML for logged-in users, navigation in the WordPress dashboard will always be entirely dependent on your source server performance. If you don’t use a performance-optimized host, tasks such as writing and publishing content, managing images and other media assets, and running maintenance routines on your WordPress site can become a very slow experience. This will have a direct negative impact on your business results.

3. WordPress membership sites and forums

if you use plug-ins such as Ultimate Membership Pro to manage your WordPress membership sites, or use bbPress to support WordPress forums, Cloudflare APO will not be able to optimize most of your traffic. Since member websites and forums usually require users to log in, Cloudflare APO will automatically bypass the HTML cache of these users. Therefore, using high-performance hosts is still the best way for WordPress member sites and forums to maintain a fast user experience.

4. The WordPress Cron job

WordPress cron (WP-Cron) helps you schedule and automate back-end tasks on the WordPress site. Your site may use cron jobs to post articles at specific times. Simple tasks like this don’t require much CPU resources, but other tasks may take up more resources. For example, tasks such as automatically backing up your WordPress site to a ZIP archive every 12 hours using the backup plug-in take up more CPU.

because Cloudflare APO only helps optimize front-end content, you still need to host your site on a high-performance host to maximize the performance of back-end tasks and the login user experience. How

uses Cloudflare automatic platform Optimization for WordPress

now that we’ve discussed why Cloudflare WordPress automatic platform optimization changes the rules of the game, let’s take a look at how to add services to your WordPress site.

APO applies to Cloudflare free and paid plans. For free Cloudflare users, you need to pay an extra $5 per month for APO. If you use a Pro, Business, or Enterprise plan on Cloudflare, you can enable APO at no charge.

here is what you need to get started with Cloudflare APO:

creates an API token in the Cloudflare dashboard.

  1. installs the official Cloudflare WordPress plug-in.
  2. enables automatic platform optimization.
  3. 1. Create Cloudflare API token

before enabling APO, you need to change the API token and install the Cloudflare WordPress plug-in. To generate an API token, click the profile icon in the upper-right corner of the Cloudflare dashboard, click My Profile, select the API Tokens tab, and then click

.Create Tokencreate Cloudflare API token

How to set up Cloudflare APO for WordPress-improve performance by up to 300%6

under “API Token Templates”, click

next to the WordPress option.Use Templateselecting the WordPress API token template

How to set up Cloudflare APO for WordPress-improve performance by up to 300%7

“WordPress” template will generate an API token with the necessary permissions to allow automatic platform optimization to function properly. The default settings are all you need to get started with APO, but if you need to lock API tokens to specific users or areas, feel free to adjust the Account Resources and Zone Resources settings. After

finishes configuring the token parameters, scroll down and click

.Continue to Summaryconfigure the Cloudflare API token parameter

How to set up Cloudflare APO for WordPress-improve performance by up to 300%8

finally, click

to complete the process.Create Tokenconfirms the creation of the Cloudflare API token

How to set up Cloudflare APO for WordPress-improve performance by up to 300%9

must copy the API token to a secure location. You will need it later when you install the Cloudflare WordPress plug-in. After recording the API token in a secure location such as the password Manager, close the page at any time.

records your Cloudflare API token

How to set up Cloudflare APO for WordPress-improve performance by up to 300%10

2. 0 in a safe place. Install the Cloudflare WordPress plug-in

Cloudflare WordPress plug-in can be installed directly from the WordPress plug-in library. To find it, search the WordPress dashboard for “Cloudflare”. Be sure to install the official Cloudflare plug-in, not “WP Cloudflare Super Page Cache”, which is the first search result.

installs the official Cloudflare WordPress plugin

How to set up Cloudflare APO for WordPress-improve performance by up to 300%11

Next, go to the

setting & gt; Cloudflarein the WordPress dashboard sidebar, and then click Sign in Here.Log in to your Cloudflare account

How to set up Cloudflare APO for WordPress-improve performance by up to 300%12

enter the email address associated with your Cloudflare account and the API token you generated earlier. Click

to complete the login process.Save API Credentialsenter your email address and Cloudflare API token

How to set up Cloudflare APO for WordPress-improve performance by up to 300%13

now that the Cloudflare WordPress plug-in is all set, let’s go to the Cloudflare dashboard to enable automatic platform optimization.

3. Enable automatic platform optimization in Cloudflare

Cloudflare Pro, Business, and Enterprise plans include automatic platform optimization of WordPress at no additional cost. If you use a free Cloudflare plan, the APO add-on costs $5 per month. To enable APO, go to

in the Cloudflare dashboard.Speed > Optimizationto enable APO, navigate to Speed & gt; Optimization

How to set up Cloudflare APO for WordPress-improve performance by up to 300%14

and scroll down to the “Optimized Delivery” section and enable “Automatic Platform Optimization for WordPress”. If you are using a free plan, Cloudflare will prompt you for billing details during this period. After enabling APO, you should see a message “WordPress plugin successfully detected on [your domain]”. If you do not see this message, we recommend that you reinstall the Cloudflare plug-in or contact Cloudflare support for further assistance.

enables automatic platform optimization for WordPress in the Cloudflare dashboard

How to set up Cloudflare APO for WordPress-improve performance by up to 300%15

in your WordPress dashboard go to the

setting in the sidebar & gt; Cloudflare. Click thebutton next to “Apply Recommended Cloudflare Settings for WordPress”– this will optimize the Cloudflare settingApplyfor your WordPress.finally, make sure that “Automatic Platform Optimization” is also enabled in the plug-in settings. TheCloudflare WordPress plug-in sets how

How to set up Cloudflare APO for WordPress-improve performance by up to 300%16

confirms that Cloudflare APO for WordPress is working

at this point, Cloudflare automatic platform optimization should be active on your site! Here is how to confirm that APO is working properly. First, make sure that the orange cloud in Cloudflare’s DNS tab is enabled for the domain of your WordPress site. If orange cloud is not enabled, Cloudflare will not proxy traffic for your domain-which means that APO will not work properly.

confirms that Cloudflare Orange Cloud is enabled

How to set up Cloudflare APO for WordPress-improve performance by up to 300%17

how to use the browser Checker to check the Cloudflare APO cache status

next, you can use the Web browser’s built-in inspector to check the HTTP headers of requests to your website. We will use Google Chrome in the following example. First, launch a new browser window in stealth mode.

launches a new invisible window in Google Chrome

How to set up Cloudflare APO for WordPress-improve performance by up to 300%18

next, go to your WordPress site, right-click the page, and select “

” to open the browser inspector. You can also access the inspectorInspectby going tomore tools & gt; developer toolsin the Chrome more buttons menu bar.Click the request for your domain (brianwp.com in the following example). In the submenu, click Headers to display the HTTP response header.uses the browser inspector to check the Cloudflare cache status

How to set up Cloudflare APO for WordPress-improve performance by up to 300%19

after enabling APO, you should see some headers related to APO. The

indicates where to provide the request. This header has several possible values– “origin, no-cache”, “origin, bypass”, and “cache”. If you see the “origin, no-cache” value of this header, the source server has sent the “Cache-Control: no-cache” header to Cloudflare. The “origin, bypass” value indicates that Cloudflare’s HTML cache is bypassed and the request is provided from the source side. Finally, the “cache” value indicates that the request is provided from Cloudflare’s cache.

  • cf-apo-viaindicates whether the page is provided from the CDN of Cloudflare. After refreshing the page several times, you should see the “HIT” status. If your
  • cf-cache-statusheader shows “DYNAMIC” after several refreshes, APO may have been bypassed due to configuration errors or cookie-related incompatibility.cf-cache-statusindicates the cache compatibility of the page based on caching instructions from your original server. This header has two possible values– “no-cache” and “cache, platform=wordpress”. When APO is properly configured using the Cloudflare WordPress plug-in, this header will return “no-cache” for pages that should not be cached and “cache, platform=wordpress” for pages that can be cached.
  • cf-edge-cacherepresents the number of seconds the page has been cached in the CDN of Cloudflare.
  • ageif you see the header above when you check the WordPress site, the APO is all set. Now, continue with the speed test to see how fast your website is! How

uses curl to check Cloudflare APO cache status

you can also use the following curl command in the terminal to confirm that Cloudflare APO is working properly. Notice that the command passes a “Accept: text/html” header. This is required when checking the APO cache status. After

runs the command, you should see a list of response headers as shown below. As you can see, the

  curl --request GET -I -H "Accept: text/html" https://www.website.com

, andcf-cache-statusheaders show that the request is serviced by Cloudflare’s cache.cf-apo-viauses curl to check Cloudflare APO cache statuscf-edge-cacheAPO automatic platform optimizationageCloudflare that does not use the Cloudflare plug-in recommends using automatic platform optimization with the official Cloudflare WordPress plug-in. This is also our recommended approach because it ensures that you get the maximum performance advantage from APO. If your site is not compatible with the Cloudflare WordPress plug-in, we recommend that you work with developers to make your site compatible.

How to set up Cloudflare APO for WordPress-improve performance by up to 300%20

if you really cannot install the Cloudflare plug-in, you can use APO without the plug-in. If you choose this route, you can still take advantage of some performance optimizations, but there are several important limitations to be aware of.

After Cloudflare APO

with the WordPress plug-in installs the Cloudflare WordPress plug-in, automatic platform optimization provides the following HTML edge caching features.

has a 30-day HTML edge cache for TTL. The cache expires within 30 seconds after a

article is published or updated.

bypasses the HTML cache for logged-in users.

  • bypasses the HTML cache of some cookie, such as WooCommerce.
  • skips requests to the source server if pages can be provided from the CDN of Cloudflare. This reduces the load on the source server.
  • Cloudflare APO
  • without the WordPress plug-in if you do not have the Cloudflare WordPress plug-in installed, you may see the following APO HTML edge caching feature.
  • has a 30-day HTML edge cache for TTL. The

cache expires

(instead of 30 seconds)

  • within 30 minutes.
  • bypasses the HTML cache of some cookie, such as WooCommerce. In order forto provide correct cache invalidation logic,still needs to make a request to the source server. As you can see,
  • has several advantages in using automatic platform optimization with the official Cloudflare WordPress plug-in.
  • SummaryWordPress’s Cloudflare automatic platform optimization is undoubtedly the most important service in recent history to improve WordPress performance. It goes beyond the usual Web server optimization, server-side page caching, and CSS/JS reduction strategies, and presents something completely new. Since the inception of

, WordPress has been limited by the fact that there is no simplified and easy way to cache HTML pages on CDN. By leveraging its network of more than 150 data centers, Workers, and Workers KV, Cloudflare leveled the performance competition between WordPress sites and static sites designed with cutting-edge frameworks.

is no small feat, and we look forward to seeing how Cloudflare will extend its automatic platform optimization capabilities to other CMS platforms in the future.

WordPress的Cloudflare自动平台优化无疑是近期历史上提升WordPress性能的最重要服务。它超越了通常的Web服务器优化、服务器端页面缓存和CSS/JS缩小策略,并呈现了一些全新的东西。

自成立以来,WordPress一直受到以下事实的限制:在CDN上缓存HTML页面没有一种简化且简单的方法。通过利用其由150多个数据中心、Workers和Workers KV组成的网络,Cloudflare在WordPress站点和采用尖端框架设计的静态站点之间拉平了性能竞争环境。

这是一项不小的壮举,我们期待看到Cloudflare在未来如何将其自动平台优化功能扩展到其他CMS平台。

Disclaimer: All articles on this website, unless otherwise specified or marked, are original and published on this website. Any individual or organization is prohibited from copying, stealing, collecting, or publishing the content of this site to any website, book, or other media platform without the consent of this site. If the content on this website infringes on the legitimate rights and interests of the original author, you can contact us for assistance.