Last week, Cloudflare released “Automatic Platform Optimization” (APO), a new performance optimization service for WordPress sites. At first glance, APO may seem like yet another WordPress optimization service, but it’s actually the most important development in the world of WordPress performance since people figured out how to do page caching a long time ago. If you use WordPress to power your site, you need to do yourself a favor and check out Cloudflare APO!

Let me tell you why.

Prefer to use your ears instead? Listen to this post below, or subscribe to Brian On WP on Apple Podcasts, Google Podcasts, and Spotify.

I was a WordPress user for a long time. The first few iterations of this blog were powered by WordPress. Nowadays, I work at a WordPress hosting company, and I still use WordPress for a few side projects. However, I no longer use WordPress for this blog anymore for multiple reasons.

  • Like I said, I work at a WordPress hosting company, which means I have to spend a considerable amount of WordPress during work hours. There are a ton of exciting web technologies outside WordPress. To prevent myself from turning into a WordPress dinosaur, I decided to move this blog to Hugo in order to learn more skills and stay up to date with modern trends.
  • I’ve used WordPress for over 10 years, and the core experience hasn’t really changed for my use case (basic blogging). The current workflow is still “log in, write something, and hit publish”. Switching to Hugo was a breath of fresh air in this respect because I actually enjoy designing and optimizing my publishing and content management workflow and tools. This is much more difficult to do with WordPress because it doesn’t make sense to reinvent the wheel from an opportunity cost perspective.
  • Static sites have more performance potential than WordPress sites by design – more on this later. Sorry WordPress maximalists, this is simply the reality of the situation. As someone who’s obsessive about web performance, the idea of using WordPress when there were inherently faster options out there frustrated me enormously. This frustration motivated me to learn Golang and recreate my blog with Hugo.

Why Static Sites are Faster than WordPress

Whenever I hear people argue about static site performance versus WordPress performance, I just try to tune it. I recommend you do the same because most people talking about this topic have no idea what they’re talking about. These debates are almost always pointless for multiple reasons.

  1. Performance is rarely the #1 consideration for why people choose static sites over WordPress, or vice-versa. If you think the top distinguishing factor between static sites and WordPress is performance, you’re just a troll.
  2. Some people in the static site crowd always assume page caching doesn’t exist. I find this hilarious because it’s pretty difficult to find a host that doesn’t offer page caching nowadays. Once a page on a WordPress site is in the cache, it’s essentially static HTML that can be served without help from PHP. Stop pretending page caching doesn’t exist.
  3. At the same time, some people in the WordPress crowd view page caching as the be-all and end-all of WordPress performance. The term “page caching” refers to two completely different things depending on the context. Static site page caching is not the same thing as WordPress page caching, so stop pretending they’re the same.

Okay, so now that we’ve established some background information, let’s talk about why I think static sites are faster than WordPress.

Static sites don’t rely on a single origin server.

That’s it.

When properly deployed on a service like Netlify, Vercel, or Cloudflare Workers Sites, static site assets (including HTML) are automatically pushed to data centers around the world. This means a visitor from USA will hit a data center in the USA, and a visitor from Japan will hit a data center in Japan. The presence of many origins essentially makes static sites origin-less – this removes the bottleneck of having to serve HTML from a single origin server.

The origin server bottleneck is something that WordPress sites weren’t able to get around efficiently until the introduction of Cloudflare’s new APO service. Previously, it was possible to add a CDN to your WordPress site. Traditional CDNs help improve performance by offloading static assets like CSS, JS, and images to various data centers around the world. What WordPress CDNs don’t help with is decentralizing HTML delivery. Thus, static sites are faster because it overcomes the origin server delivery bottleneck, which in itself is a physics problem.

Cloudflare Automatic Platform Optimization for WordPress Benchmarks

Before we dive deeper into how Cloudflare Automatic Platform for WordPress works, let’s take a look at a performance benchmark. A few weeks ago, I was able to test out Cloudflare APO for WordPress with Kinsta. For this test, I used a WordPress site hosted in Tokyo, Japan. Check out the chart below for the final performance benchmark results from Kinsta.

Kinsta (s)Kinsta w/KeyCDN (s)Kinsta w/Cloudflare APO (s)
Vancouver1.72.10.9
Hong Kong1.20.90.7
London2.41.60.6
Dallas2.11.70.8
Mumbai3.72.30.9
Sydney2.91.20.6

As you can see, adding Cloudflare APO for WordPress has a significant positive impact on page speed. Kinsta’s benchmark test shows a performance increase from 70-300% without any additional optimizations beyond enabling Cloudflare APO. Digging into the test results further, you can see the locations farthest away from Tokyo, Japan (the location of the origin server) saw the biggest improvements in load time. This is in line with Cloudflare APO’s core objective of distributing HTML to data centers that are the closer to the visitor.

How Cloudflare APO Speeds Up WordPress

To put it simply, Cloudflare Automatic Platform Optimization for WordPress solves the origin bottleneck problem by turning your WordPress site into a multi-origin web entity. With APO enabled, HTML no longer has to be delivered by an origin server in a single location. Your origin server will still be used to create and publish content, but it will no longer be used to directly serve HTML to visitors.

Let’s get into how Cloudflare APO workers exactly. APO is powered by a few amazing Cloudflare technologies – edge network, Workers, and Workers KV.

  • Edge Network: Cloudflare’s edge network consists of high-performance servers in over 150+ locations around the world. The omnipresence of Cloudflare’s edge network means Cloudflare services are less than ~10ms away from Internet users in the developed world. This is why web assets cached and served by Cloudflare are fast wherever you are in the world.
  • Workers: Cloudflare Workers are JavaScript service workers that can be used for HTML rewriting, dynamic content fetching, image optimization and more. Since Cloudflare is a proxy service, Workers scripts can be used to intercept and manipulate HTML responses before it’s sent back to a visitor.
  • Workers KV: Cloudflare Workers KV is a high-performance globally-distributed key-value storage service. It offers low-latency global replication of stored values, which makes it a great solution for storing values that need to be accessed around the world.

Okay, so how do Workers and Workers KV work together with Cloudflare’s edge network to speed up WordPress sites?

Request and response flow for Cloudflare APO for WordPress.
Source: Cloudflare

When APO is enabled, Cloudflare essentially creates a mirror of your WordPress site in Workers KV. If you think about it, web pages are prime candidates for a key-value storage service. Each page on your WordPress site has a unique “key” in the form of a URL. Similarly, the minified HTML of the page is the “value” that is stored in Workers KV. Recall that Workers KV automatically replicates data across the entire Cloudflare network.

Thus, with Workers KV, Cloudflare can maintain a distributed database of key-value entries that represent your WordPress site’s posts and pages.

The next piece of the puzzle is Cloudflare Workers. When APO is enabled, requests to your WordPress site are intercepted by a Cloudflare Worker. Recall that a Cloudflare Worker is simply a service worker that can be programmed with JavaScript to do something. In this case, the Cloudflare Worker includes some WordPress-specific logic that allows it decide what to do with a request.

For example…

  • If a request is made to your site, the Worker checks the URL against the present keys in Workers KV. If a matching key (URL) is found, then the corresponding HTML value is served directly from Workers KV.
  • If a request is made to your site and the key is not found, Cloudflare will make a single request to your site and store the response in Workers KV. After that, the new page stored in Workers KV will automatically replicate around the world without making any additional requests to your site.

The Cloudflare Worker for APO also has some WordPress-specific logic for handling certain classes of pages. For example, pages for logged-in users are routed to the origin server because backend dashboard pages should never be served from cache. Similarly, pages containing certain cookies (e.g. woocommerce_items_in_cart and wordpress_logged_in) are routed to the origin server as well. This is important because WooCommerce shopping carts and checkout pages can contain personally identifiable information.

Lastly, Cloudflare’s edge network ties APO all together. With its extensive network of data centers, Cloudflare APO truly becomes a meaningful and powerful performance optimization service. With APO enabled for your WordPress site, visitors from around the globe are able to be served by nearby Cloudflare data centers without ever having to request pages from your origin!

Until now, this concept of origin decentralization simply did not exist in the world of WordPress. Sure, there have been various attempts at fully caching WordPress sites with Cloudflare. In fact, I wrote about how to do this by hacking around with Cloudflare page rules myself. I’ve seen quite a few people comment on the similarities between Cloudflare APO and the old full page caching method. Some have even gone as far as to say Cloudflare APO (at $5/month for free plans and $0/month for paid plans) is just a money grab – lol. In reality, the two methods are worlds apart and should not even be compared. Let me tell you why!

The old full page caching method did not have the luxury of a programmable proxy layer in the form of a Cloudflare Worker and an auto-replicating distributed storage layer in the form of Workers KV. This means it wasn’t really possibly to logically serve requests based on predefined parameters. In practice, this meant that it was only possible to “serve from cache” or “don’t serve from cache”.

With the old method, a visit to your site to Europe wouldn’t speed up visits to your site from Asia. In order for every page on your WordPress site to be served from Cloudflare cache, each page had to be accessed from hundreds of locations around the world to prime Cloudflare’s extensive edge network. While the full page caching method did offer some performance benefits for a site’s primary geographic audience, it did not really utilize the full potential of Cloudflare’s network in an efficient and meaningful way.

Enter Cloudflare Automatic Platform Optimization for WordPress.

With APO, Workers KV distributes your WordPress site’s HTML all around the world without any manual intervention and CDN cache priming. To take it one step further, a Cloudflare Worker is able to make decisions regarding how to serve your site on a request by request basis – intelligent granularity is awesome. Finally, Cloudflare’s extensive network of edge servers caches HTML served by Workers KV for an “icing on the cake” performance boost.

In addition to caching HTML pages, Cloudflare APO also caches third party fonts. This means if you’re using Google Fonts on your WordPress site, APO will serve those fonts from Cloudflare’s CDN cache instead. This optimization is yet another example of the power of Cloudflare Workers. In order to serve fonts from Cloudflare, the APO Worker actually rewrites the HTML response’s HTML and inlines CSS to point the font source to Cloudflare.

Cloudflare APO’s font caching feature really highlights the dynamic and programmable nature of the service. Since APO is powered by a programmable JavaScript service worker, I wouldn’t be surprised to see Cloudflare add additional features to APO for WordPress over time.

How to Leverage Cloudflare APO Correctly

Cloudflare Automatic Platform Optimization is a huge win for the WordPress community, but I want to stress the fact that APO isn’t some sort of magic bullet that will make all your problems go away. On a technical level, APO is a “mirror” powered by Workers KV – it’s not a “source of truth”. Thus, the source of truth, or the origin server, is still an important part of an APO-enabled WordPress stack.

The point here is that you shouldn’t suddenly move your WordPress site to a cheap host after setting up Cloudflare APO. Even with APO enabled, WordPress is still ultimately a dynamic software experience at its core. At the end of the day, WP cron jobs, AJAX calls, and backend administration will still function better on a high performance WordPress host like Kinsta.

Don’t look at Cloudflare Automatic Platform Optimization as an excuse to scale down origin server performance. Instead, look at it as a tool to help you maximize the potential of your existing WordPress hosting stack.

Is Automatic Platform Optimization Worth It?

If you’re on a Cloudflare Pro, Business, or Enterprise plan, you already have access to Automatic Platform Optimization for WordPress at no additional charge. In this case, enabling APO would be a no-brainer. For Cloudflare users on free plans, APO is a $5/month add-on. That’s the price of two cups of coffee at Starbucks! If your WordPress site is compatible with APO, it’s totally worth it. However, if the majority of your traffic bypasses cache (WooCommerce stores, bbPress forums, etc.), then I’d recommend doing some analysis on what percentage of traffic APO would benefit before making a decision.

Summary

The implications of Cloudflare’s Automatic Platform Optimization for WordPress cannot be understated. For the first time in history, WordPress sites have the ability to compete with static sites and SPAs from an origin-decentralization perspective. In practice, implementing APO can have real effects on SEO rankings (Google takes page speed into account) especially in regions far away from your origin server. For businesses, this could translate into more sales due to a higher clickthrough rate from Google and a lower bounce rate due to a faster time to interactive. I’m very excited to see how Automatic Platform Optimization changes the WordPress performance game in the coming months.