Regardless of your experience with WordPress, it’s almost inevitable that – at some point – you’re going to want to experiment with caching your website.

Cache, Not Cash

Cache, Not Cash

For those who have a background in computing, you’re likely already familiar with caching:

  • how it works,
  • how to control it,
  • some of the pitfalls,
  • and many of its advantages.

If, on the other hand, you’re someone who wants a faster site, finds a plugin, and then begins turning options on and off, you may end up negatively affecting your site in some way.

Because WordPress is available a one-click install on so many web hosts, and because the plugin repository has a variety of caching plugins, it’s easy to get overwhelmed and/or try out a number of different plugins potentially altering the appearance of your site when users are viewing it.

And the latter happens to all of us. At least I hope. I had a cache issue late last week :).

Anyway, despite this laborious introduction, the purpose of this post isn’t necessarily to outline the advantages and disadvantages of caching. Instead, it’s meant to answer the question:

Should I use caching on a shared web host?

And though it’s not a difficult question to answer, it’s important to understand that you can only push the limits of your caching so far in that type particular environment.

Caching on a Shared Web Host

First and foremost, this is not a post promoting a particular plugin or service for caching. Instead, it’s meant to act as a simple answer to a question that I occasionally receive via email.

To that end, you’re not going to find any recommendations for plugins in this post (maybe in a future post).

Anyway, so when you’re on a shared web host, that means that your site is sitting alongside n-number of other sites on the same machine (or set of machines). So if the machine on which your site is hosted goes down, then all of the sites on that machine go down. You’re, you know, sharing the machine.

Hence the name.

The tradeoff is that you get cheaper hosting but less control over your server. As such, you don’t get to tweak some of the things such as server software, database performance, etc. as you would if you were using a dedicated server.

With that said, we still haven’t answered the initial question. The general answer:

Yes, you should use caching on a shared web host, but you won’t get the same benefits as if you were on a dedicated server.

In other words, sure! You’ll get some benefits, but not all of the benefits. And that’s okay, right? We don’t all have the desire or means to maintain a dedicated server, but why not make the most of what we have?

Here are the general notes I usually provide to others when considering caching on a web host:

  • Do not cache pages for users who are logged in, including yourself. You always want to have the most up to date information for your site. If you’re accessing cached information, you’re not doing that.
  • Be careful with automated CSS minification. Many times, if you allow a plugin to do this for you, you’re likely to notice that your site doesn’t look at all like it should. This is because something is being misapplied during the minification process. Although you’re decreasing the file size and the number of requests, you’re losing the presentation of your site.
  • Combine your JavaScript files, but test them. This is predicated on the idea that you know what each of the JavaScript files does. The more plugins you have running on your site, the more likely this is going to be difficult to test. But if you’re on the up and up with what the scripts are doing on each of your pages, then try to combine them and then test to make sure no functionality is lost. Once again, you’ve got fewer files and fewer requests.
  • Set your page cache. This may also be represented as “HTML minification” or something similar. When you view the source of a web page, the markup usually has a human readable flow (at least, sort of). When you minify your HTML, you’re basically placing all of the HTML on a single line (that will likely be word-wrapped in whatever editor you use to view the source). This is arguably one of the safest things you can do in order to cache your pages.
  • Browser Cache. This is a setting many plugins offer that will provide some extra information in the data sent along with your page that will instruct the browser to cache some of the assets on your visitors’ computer. This will help the page load faster when they revisit it.
  • Set a Cache Expiration. Most plugins will allow you to set a length of time – in seconds – that you can set your cache to expire. I recommend doing this because you don’t want to hold the same version of a page or your site in memory indefinitely. In fact, you’d really like to update the cache when a new comment is posted or a new page or post is published, but this is getting more into plugin configuration than it is general rules of thumbs to follow.

What About a Content-Delivery Network?

Regardless of whether a person is using a caching plugin, one of the questions that inevitably comes up along side this topic is:

Should I be using a content-delivery network?

Some will say yes, but I tend to say “it depends.” If you have a relatively busy site and you have visitors all over the world, then I’d say yes. You should be using a CDN.

In terms of what you should be using, that all depends on how busy your site is and the budget that you have. The top three available options that you’re likely to find are:

  • Photon is a Jetpack module that will allow you to automatigically host your images from one of the various data centers offered by Automattic. It does not include hosting of assets such as JavaScript and CSS, but it’s a good first-pass at speeding up your site.
  • CloudFlare is available on many web hosts and can be setup in the control panel of the site. In short, it’s a popular way to easily setup a CDN to host your images, your stylesheets, and your JavaScript files. CloudFlare also offers some security options. This is nice, but those security options might negatively impact speed as it works to determine if the incoming request is safe or not. As with many things, there’s a tradeoff.
  • MaxCDN is a service that does not offer a free plan (though the lowest tier is just $7.50 a month), and they do not offer the type of security options that CloudFlare does. That doesn’t mean there aren’t options for security (there obviously are), but acting purely as a CDN can help improve the speed of the site.

Sure, there are others, but if you’re on a shared host and are looking to squeeze out as much performance as possible, then these are the ones that are worth checking out. Of course, if you have others to recommend, please feel free to do so below.

What Do I Use?

As mentioned earlier, this post isn’t about promoting any particular plugin that I use. I will say, though, that I have some sites on shared hosts and some on dedicated hosts and I’ve always used some form of caching in the most recent years.

In a future post, perhaps I’ll outline what I prefer in terms of WordPress caching. For now, though, I’m interested in whatever it is you have to add to this particular post.

If there’s a plugin and/or CDN you’d like to recommend (or not), or a general rule of thumb that I neglected to cover in the post, then please feel free to share it in the comments.