Caches and Why We Clear Them

So you have great new business website. You’re using quality hosting that’s appropriate for website size and scope, and it’s performing pretty well, but could it perform better? There are other things you can do to help your website be as fast as possible, to reduce it’s size, and to minimize the impact it has on your server and hosting.

Caching can have a huge impact on your website. It can make it load more quickly for your users. It can reduce the number of files and the size of the files that a user’s browser needs to download when they visit your site. It can also reduce the resources that your web server uses – this can be especially helpful if you’re on shared hosting or if your hosting package has resource limitations.

What is Caching?

Caching is a process where we use specific instructions in the code of your website to tell your web server, CDN, or the user’s browser whether or not to save parts of your website locally. This means HTML, CSS, JavaScript, and image files can be saved locally on a users computer, or parts of a website can saved in memory on your web server so they can be accessed more quickly. There are several different types of caching when it comes to websites. The most common types are below.

Types of Caching

Browser Caching
Browser caching is the level of caching closest to the user. All the files that a website serves to a browser have special instructions called cache expiry headers. These instructions tell the web browser how long to store copies of the files locally on the user’s computer. By keeping these files stored locally, the user’s browser doesn’t have to download them again the next time they visit the website. This makes their experience faster overall.
Database Caching
Most websites today are made up of at least two parts today: the website, and the database. For a platform like WordPress, all your settings, content, links, posts, and pages are stored in your database. When a user visits a post or page, the website has to query the database to retrieve whatever content belongs to that page. Database caching keeps the content for the most frequently used pages and posts stored in server memory so that the website doesn’t have to query the database every time.
Object Caching
Object caching allows a website to store specific information in server memory. This is usually information that is accessed frequently or that may otherwise be resource intensive to request over and over. This is different from database caching in that it’s much more specific.
Page Caching
Most modern websites are built with some kind of content management system. WordPress is one of the most popular of these. CMSs, by their nature, build a web page out of multiple pieces (headers, footers, navigation, content, plugins, themes.) Page caching pre-builds those pages before a user visits them, and saves those static, complete versions of the pages in server memory. The pages are able to be downloaded more quickly this way and use less server resources.
Edge Caching
Edge caching or using a content delivery network (CDN) adds another technical layer between the user and the web server. This additional layer is based on geography and distance. Services like Cloudflare, Akamai, or Amazon Cloudfront have huge networks of servers around the US and the globe. They deliver copies of a website’s files to the user from the closest regional server. This can lower response times, reduce server load, and improve overall performance.

Caching Considerations

While caching is a very effective tool, it is not one size fits all. There are things you need to consider in determining what settings and configuration to use.

How often do you update your site?

Are you adding new posts or pages to your site once a week? Multiple times a day? Do you have an ecommerce site where you are adding new products or they are changing constantly? Depending on how often you make updates, you’re going to want to set your cache expiration to match. Caching pages for weeks is going to cause problems if you’re updating content every day.

What types of static content do you have on your site?

Is your site heavy on images? Are you hosting or embedding video? Is your site heavy on custom CSS and javascript animations? Depending on the answers to these questions you may or may not want to do things like minify and combine HTML, CSS, and JavaScript. You may want to host your images on an external CDN. Are you using custom fonts? Should they be hosted locally or be delivered from Google’s CDN? These are all decisions that can impact how you implement your caching configuration.

What types of dynamic content do you have on your site?

Does your site have dynamic content? Do you have plugins loading content from Instagram or Facebook? Do you have personalization on your site for customers? Things like this should be being handled with AJAX, but if they are not, caching pages that have this functionality could cause problems.

Where are your users located?

Is your business fully local and you contained to your neighborhood or city? Do people from Europe or Australia regularly access your content? Are you running a web store and your products popular all over the country? Depending on the geography of your online presence, a CDN service like Cloudflare could be hugely impactful. Cloudflare has more than 150 server locations all over the globe. Having cached versions of your site content in their regional edge cache, could greatly improve the experience of your users across the country, or on another continent.

Common Caching Issues

One of the single most frequent things we run into is “Help! I updated a post/page/theme/plugin and my site is broken!” This happens ALL the time. Many people are quick to blame the theme or the plugin. It must have been a bad update. The developers must have done something wrong. While this is a possibility, it is rarely the case. It’s almost ALWAYS a caching issue. When you update posts, products, or pages and the new changes don’t show up immediately, it’s usually because the old version is cached on the server or the user’s browser. The caches just need to be cleared and updated as well.

More seriously, when you update themes and plugins, the code to the site changes. Themes and plugins can be made up of dozens or hundreds of files. When they are updated, not ever file changes, but many do. If you have caching enabled on your site, server, or have browser caching instructions on your site, this can cause major issues. The wrong versions of the code can be saved on the server, or in a user’s browser. When the browser tries to load old versions of the code mixed with new files from the update…things can and will break. This does not mean something is wrong with the theme, or with the plugin, simply that you need to clear your caches!

Recommended Caching Solutions

This is a list of recommended plugins to help you with caching on your WordPress site. Some plugins will work better with certain hosting environments or configurations. If you don’t have great success with one, you can try another.

Swift Performance Lite/Pro

Swift Performance is a relative newcomer, but it’s an excellent plugin. We use it on quite a few sites and have had some great success. There is a free version and paid version, but even the free version has a robust feature set. The premium features are worth the additional price if you decide to upgrade. There is a bit of a learning curve.

WP Rocket

WP Rocket is an excellent paid plugin. It has a full feature set and is very user friendly. For most situations you can use their recommended settings and get great results. Their customer service is also great.

Cache Enabler

Cache Enabler is a very simple and straightforward plugin. It’s developed by the people from KeyCDN and it’s got a great reputation for working well with it’s limited feature set.

Hummingbird

Hummingbird is another plugin that has free and paid versions. The free version has a solid feature set and an easy to use interface. The paid version has additional features but is only available as part of a bundle.

CDN Options

Cloudflare

Cloudflare is more than just a CDN, it also provides security features, DNS management, and caching across their entire global network. Their free offering doesn’t really have anything that can compete and their paid features are very robust.

KeyCDN and StackPath

KeyCDN and StackPath’s offerings and pricing are very similar. Their CDN features are both solid and easy to use. They don’t have quite as many features as Cloudflare, or the sheer size of their network, but they are both great options.

Recommended Update Procedure

  1. First, if your hosting has a staging environment, use it. If not it’s recommended that these steps are first done on a local development copy of your site.
  2. Second, and most importantly, make sure you take a backup of your site.
  3. Third, update your plugins. Check to see if there are any issues after each one. Clear your caches (ALL of them. Your server cache, page cache, browser cache, object cache, and edge cache/CDN all need to be cleared.)
  4. After your plugins are updated, you can go ahead and update your theme. Clear your caches. Check to see if there are any issues.
  5. Finally, update WordPress. Clear your caches. Check to see if there are any issues.
  6. If you successfully complete these steps on your local development or staging site, repeat the process on your live site or push the staging copy to live.

Let’s get started
on your next project

If you’d like help enabling caching, setting up a CDN, starting a new project, or managing your existing sites, let us know! We’d love to help you.

Interested In: