Improve Page Cacheability to Optimize Speed

Cached requests, or cacheable requests, are pages on a website that are essentially static in nature and can be stored in memory to be served very quickly. Cacheability can be defined as the ratio of website requests that are served from cache compared to uncached requests, commonly referred to as dynamic requests. Increasing your website’s cacheability can be directly linked to a higher performing website that scales smoothly with increased traffic.


About Cache

When a request for a page on your site comes in it is sent to the server for the code to be generated. This alone doesn’t cause much strain for the server, as it’s pretty easy to serve just one page. The stress becomes much more apparent when the server has to build multiple pages per second. Caching helps ease the strain on the server by storing the previously generated page code in cache.

When a page request comes to the server, it first asks whether the page is in cache. If the page is already in cache, it’s served quickly and easily to the visitor. If not, it’s sent to the server to be built and then served. On its way back it also stores a copy of that page within the caching layer. The next time a request for that page comes in, it can be served from the caching layer, instead of having to be built like new.

This lightens the workload of the server, which means it can handle way more traffic at once than it otherwise could. It also speeds up your site, because serving a page from cache is much faster than building it new every single time. This is the type of caching that our WP Engine page cache uses to help improve your site’s performance.

By default the WP Engine Page Cache™ holds on to the content it stores for 10 minutes. This means every 10 minutes, the process of storing a new “snapshot” in the caching layer repeats itself.

Learn more about caching, cache length and how to purge cache in our guide.


Object Cache

We also offer a layer of “object caching”, which caches the results of repeated queries to the database. For example, if you have a WordPress plugin on your website, these would be stored in your database.

Your website would then require that list of redirects to load every time a page is loaded, by running a query to the database. The server first looks for the list of redirects in the Object Caching layer.

If a saved query result doesn’t already exist in the Object cache, the query is run in the database and the result is stored in the Object Caching layer for the next time a page is loaded.

To find out more about this type of caching, read our Object Caching article here.


About Cacheability

Cacheability is simply the percentage of visits to your site that are cacheable, compared to those which are uncacheable.

  • Static content (files which rarely change) like CSS, JS, and images for example, are easily cacheable.
  • Dynamic content like login pages, shopping carts, and membership-only areas are not cacheable because they require the screen to show something unique to each person visiting it. A saved “snapshot” of the page wouldn’t work in those cases, meaning those pages are “uncacheable”.

A higher cacheability score indicates a faster site, better search rankings, and a lower bounce rate as a result (making for a better overall experience for visitors).


Optimize Dynamic Content

Uncacheable, dynamic content is great in that it “personalizes” your site’s content to the specific visitor. However, generating this content new on every page load can be very taxing on the server, meaning your site won’t scale as well once you start receiving a lot of traffic. Sites that limit the amount of content that needs to be compiled new on the server every time will always present a faster, better experience for your visitors.

User Segmentation

We have created a unique option within our proprietary page caching system to allow developers to create page variations for different types of users, while still caching your pages. Learn more about how it works in our User Segmentation article!

GeoTarget

One struggle developers have dealt with through the years is how to personalize content for different geographic regions, while maintaining the highest cacheability (and scalability). At WP Engine, we’ve come up with a solution for websites with worldwide markets: Our revolutionary GeoTarget system. This system allows you to serve different content to different areas of the world: by region, zip code, country, and more. And it also works within our caching system, by separating each area into its own “caching bucket.”

This means, for example, when a customer from Canada visits your site, they can view the custom content you’ve created for Canadian visitors, and stores a copy of this content in the “Canada” cache bucket. Then, the next visit from Canada can view a cached version of the site, which is served quickly and doesn’t need to be compiled by the server. Then, when a visitor from the USA visits the site, their version of the page is stored in the “USA” cache bucket, for the next USA visitor to see the cached version. The same would be true of any region with custom content you’ve created.


Improve Cacheability

Now that you know why caching is important, you may be wondering: how can improve my website’s cacheability? In this section we will cover recommendations when hosting with WP Engine, as well as recommendations that can be used when hosting anywhere.

WP Engine-Specific Recommendations

pp_overviewfeature-2

At WP Engine, we offer Page Performance tools within your User Portal, which gives you a cacheability score for your site. It’s understandable that you might want to improve this score, considering all the benefits of caching! Below are a few ways you can increase your site’s cacheability, and with it, your site’s performance.

  • Use a CDN: for Professional level plans and up, CDN through MaxCDN is available to be used. CDN stands for Content Delivery Network, and in short, it helps serve and cache your site’s static, cacheable content from multiple worldwide server locations. This helps improve performance for every area of the world, and not just the visitors closest geographically to your site’s server.
  • Use GeoTarget: For Business level plans and up, GeoTarget through WP Engine is available. This is especially important for sites which want to display different content dynamically to visitors from different areas of the world. Rather than using a third-party plugin which generates uncached results for different locations, try using GeoTarget instead.
  • Customize Page Variations within Caching: WP Engine allows for users to create multiple page variations to show to different types of users within its page caching system. Learn more about User Segmentation and how you can implement it.
  • Increase Cache Expiration Time: You can configure pages to be cached for longer periods of time using the WP Engine Advanced Cache plugin. This will help ensure optimal cacheability and scalability on your site. Learn how to leverage browser caching with cache-control headers.
  • Object Caching: Ensure you’re using our Object Caching layer, which comes free with every plan. You can enable Object Caching in your User Portal by navigating to the Overview page for your environment, then Utilities from the left-hand navigation menu.              screen-shot-2016-07-20-at-6-58-50-pm-1

Recommendations on Any Host

  • Reduce external resources: If you’re calling an image, stylesheet, font, or other resource from a site that’s not hosted on our platform, it’s subject to the caching settings (if there are any), from the server that external resource resides on. Whenever possible, call these resources from your own site, so they can be served using the WP Engine caching layer.
  • Drop login requirements: For sites with memberships, asking users to login to the site creates an uncached environment for users. This means the resources and pages of the site will not be utilizing the caching layer. Dropping the requirement to login can definitely help improve cacheability.

Cache Caveats

  • Sites with higher traffic will see the most benefit to caching. If a site only receives a visit once every couple of hours, it would already be generating the page as new from the server every time, since our caching layer only stores that “snapshot” for 10 minutes.
  • Plugins and themes which use PHP Sessions to serve dynamic content to customers may not function correctly, due to caching. Read more here.
  • If there is a specific page (other than your site’s home page) which you need to be exempt from caching (like a custom login page, for example), contact Support through Live Chat–available 24/7–to request this.

NEXT STEP: Learn how to brace for a surge of traffic

Geographically customize content

Customize page content for your users based on their location without compromising cache or performance using WP Engine's GeoTarget.