Learn how to serve your WordPress site directly from Cloudflare's edge network and provide a consistently fast experience for your visitors.
- Benefits of Automatic Platform Optimization
- Availability of APO
- Using APO with Cloudflare's WordPress Plugin
- Using APO without Cloudflare's WordPress Plugin (Not Recommended
- Query Parameters and Cached Responses
- Page Rule integration with APO
- Plugin Compatibility
- Disabling APO
With Automatic Platform Optimization (APO) Cloudflare will serve your entire site from our edge network, ensuring that customers see improved performance when visiting your site. Typically Cloudflare only caches static content, but with APO we can also cache dynamic content like html so the entire site is served from cache. This removes round trips from the origin drastically improving TTFB and other site performance metrics. In addition, to caching dynamic content, APO caches third party scripts to further reduce the need to make requests that leave Cloudflare's edge network.
With APO, you don't have to change how you manage your WordPress site. Whenever updates to content are made, by using Cloudflare's WordPress plugin, we can update content in our edge to ensure that we do not serve stale content. Additionally, for logged in or admin users we will bypass the cache ensuring that private content is not cached and served to other visitors.
See our announcement blog for more information
Benefits of Automatic Platform Optimization
Serving your entire site from Cloudflare's edge provides a set of performance benefits that are unmatched by typical cache services or other WordPress plugins. Time to first byte (TTFB) is massively reduced since the first file served, the html, is served directly from our edge. This along with reducing other requests that might leave Cloudflare's network means sites start to display content sooner (First Contentful Paint or FCP).
Availability of APO
APO is included in all Professional, Business, and Enterprise plans at no extra cost.
APO is available to free plan customers on a $5 per month basis.
Using APO with Cloudflare's WordPress Plugin
Using APO with Cloudflare's WordPress plugin ensures the best possible performance and fastest cache refresh times since the plugin will update the edge whenever changes are made in WordPress.
When using the plugin the following applies:
- HTML edge caching with 30 days TTL
- 30 seconds or faster cache invalidation
- Bypass HTML caching for logged in users
- Bypass HTML caching based on presence of WordPress specific cookies
- Decrease load on origin servers. If a request is fetched from Cloudflare CDN Cache we skip the request to the origin server.
The easiest way to enable APO is directly from Cloudflare's WordPress plugin.
First install the plugin:
- Visit “Plugins” → Add New
- Search for Cloudflare
- Activate Cloudflare from your Plugins page.
Then activate the plugin with your Cloudflare user email and an API Token:
- Go to https://dash.cloudflare.com
- Login with your cloudflare account. If you don’t have a Cloudflare account, first sign up for Cloudflare.
- Navigate to the API Tokens section of the user profile (found in the top right corner of the dashboard).
- Select ‘Create Token’
- Select the ‘WordPress’ Template
- Select the Account and Zone to grant the plugin access to
- Then select “Continue to Summary” and “Create Token”
- Copy your API Token
- Return back to WordPress Cloudflare Plugin page
- Enter your email address and paste your API Token
- Press Login.
Then activate APO in the plugin from the 'Home' tab. If you are on a free plan then you will be redirected to the Cloudflare dashboard to purchase APO. After purchase, you can toggle the service on and off from either the plugin or the dashboard.
Enabling APO on a subdomain
- Install Cloudflare's WordPress plugin version 3.8.6 or later on the subdomain.
- Login using Global key (API token only works on the root domain)
- Enable APO feature
- You should see the subdomain in the list of hostnames in the card
- Repeat the process for all subdomains you want to enable APO
When activating APO on a subdomain as a part of the migration, APO will be disabled on a root domain automatically. If you are still interested in running APO against the root, please upgrade WordPress plugin version 3.8.6 or later on the root domain and re-enable APO.
Using APO without Cloudflare's WordPress Plugin (Not Recommended)
While it is possible to use APO without using Cloudflare's WordPress plugin it is not recommended to do longer lengths of serving stale content after changes are made. When not using the plugin the following applies:
- HTML edge caching with 30 days TTL.
- Cache invalidation may take up to 30 minutes. A manual cache purge can be triggered to speed up cache invalidation.
- Bypass HTML caching based on the presence of WordPress specific cookies.
- No decreased load on origin servers. If a request is fetched from Cloudflare CDN Cache we still require an origin response to apply cache invalidation logic.
Query Parameters and Cached Responses
By default, if query parameters are found in the URL - APO will bypass the cache and attempt to get a fresh version of the page from the origin. We do this because query parameters are often a sign of dynamic content being present.
We also realize that query parameters are often used for marketing attribution (ie UTMs) and that it’s doubly important that these users experience quick loading times. To enable this, APO will still serve cached content as long as the query parameters in the URL are one of the following:
Page Rule integration with APO
The following Page rules can control APO:
- Cache Level: Bypass
APO will bypass page with response header “cf-apo-via: origin,page-rules”
- Cache Level: Ignore Query String
APO will ignore all query strings when serving from Cache
- Cache Level: Cache Everything
APO will cache pages with all query strings. Default cookies rules still apply. Please note automatic page purge via the WordPress plugin won’t clean all cached pages, only one without query strings. Cached responses will be returned even with request header cache-control: no-cache.
- Bypass Cache on Cookie (Biz and Ent plans only)
APO will apply custom bypass cookies in addition to the default list.
- Edge Cache TTL
APO will apply custom Edge TTL instead of 30 days. It is helpful for pages that can generate captchas or nonces.
- Browser Cache TTL
APO will apply custom Browser TTL for all assets apart from the HTML page. The limitation is due to the technical issue we hope to address in future releases.
Note: Any changes to Caching page rules require Cache purge to see the effect.
There are over 50,000 WordPress plugins currently available for download. Because there are so many, it’s impossible for us to test the compatibility of APO with each one individually.
We do acknowledge, however, that it’s important to provide some guidance around some of the more popular plugins. To that end, we wanted to publish a list of officially supported plugins, as well as those we know to cause issues while APO is turned on. We plan on updating this list periodically as we discover new issues and add additional compatibility.
If you have a question about a specific plugin that’s not found on this list, please create a thread in our community and we’ll do our best to answer your questions.
- Easy Digital Downloads
- YITH WooCommerce Wishlist
- WP EasyCart
- Ecwid Ecommerce Shopping Cart
- WP ECommerce
Plugins and Services Reported by the Community to Cause Issues with APO
- WPTouch (Free Version)
- WP Rocket
- W3 Total Cache
- Mobile Detect
- Profile Builder
- WordPress Mobile Pack
- WP Mobile Edition
- Any Mobile Theme Switcher
- Easy Social Share Buttons
- Jetpack (Mobile Theme)
In order to disable APO, first, turn off the feature from the WordPress plugin or Cloudflare Dashboard, then purge the Cloudflare cache to ensure that content is served by the origin and respects the default origin configuration going forward.
How to verify APO and the WordPress integration works?
- Publish a change on the website page.
- You should see the change and the page should be cached with cf-cache-status: HIT in a response header. Below is an example of how to check the cache header using curl.
curl -svo /dev/null 'https://example.com' -H 'accept: text/html' 2>&1 | grep '< cf-cache-status'
Why isn't WordPress detecting APO?
The best solution is to enable APO via WordPress plugin. This should automatically resolve the WordPress detection issue.
How to report Cloudflare-WordPress plugin issues?
In terms of supporting the WordPress plugin, please file any new issues to the Cloudflare-WordPress Github repository. The management and development of the Cloudflare-WordPress plugin will be via Github.