Caching and Flushing: Optimizing Your Website’s Performance

Sometimes our clients turn to us for a deeper understanding of how their Drupal or WordPress sites work so that they can do the work they do best in less time.  Educating our clients in getting the most out of their sites is one of our core strategies to help them meet their business or organizational objectives.

design-buildOne of our Drupal clients was adding a press release to their web site. The press release concerned a joint event with another organization. They needed the PR person from that organization to review the press release and suggest changes before they notified media outlets about it. Time was of the essence in getting the final press release out. But they weren’t seeing the changes in real time due to caching.

How Caching Works

Pages on a Drupal or WordPress site aren’t static. They allow you to serve up custom content to site visitors based on an infinite number of variables that you customize. This means you can give a paying customer access to special content that an anonymous user can’t see, or you can display a calendar block that shows events sponsored by your organization in the coming week. To decide what content should be displayed, the server performs a series of computations.

Since we had redesigned their site, our clients had seen a significant increase in traffic. The required computations put a load on the server and can slow down the time it takes for the server to deliver the content to site visitors. To overcome these problems, it is standard practice to enable caching on the server. This performs the calculations once and then stores the computed results for a specific amount of time to be delivered on demand if requested again.

Benefits and Drawbacks of Caching

Using caching on a Drupal or WordPress site offers benefits both to your company or organization and your site visitors:

  • It means faster page loads for visitors, optimizing their experience of your site.
  • It decreases the load on your server, which decreases costs associated with hosting the site.

This is particularly useful with anonymous visitors to your site, often potential new customers or members you don’t want to lose due to a slow loading or unavailable pages.  Anonymous visitors are not likely to need to see a different version of a page from the last visitor. Displaying upcoming events for the next week is something that doesn’t need to change more than once a day, so a block like this can safely be cached for some time without risk of serving up stale information.

However, in the case of our client, they wanted to make repeated edits based on continuous feedback from the PR person from the partner organization while talking to her over the phone. The cache was keeping the same version of the press release for an entire hour, so she wasn’t able to see changes as they were made. Caching is not without such drawbacks:

  • Time-sensitive content  may not be up-to-date
  • Changes to content in the database may not appear to the visitor immediately

Flushing the Cache

It is important to know when to flush data from your server.

Sometimes you need to flush
the cache. (fotografar/flickr)

Our client needed to display the latest version of their press release immediately for feedback. We suggested a couple  solutions. The viewer could simply log into the site. Within Drupal, different items are cached for different time periods, or not cached at all, depending on whether the visitor is anonymous or a registered user. Since logged-in viewers see content that is customized for them, only some content they see may be cached. By logging into the site, she would have seen the changes to the press release just by refreshing the page in their browser. But because she wasn’t from their organization, they could not give the PR person access this way.

Our client had been flushing the cache via the “Flush All Caches” feature in Drupal, but they were worried about how this might affect the site’s performance, so they asked us about the drawbacks of flushing. Here’s how we immediately responded:

Flushing would make the load time for the first visitor to a specific page longer. Caches  aren’t built until someone visits an area of the site, so the first visitor might notice some slowness. However,  the effect of flushing is unlikely to dissuade the first visitor and it won’t affect subsequent visitors to that page.

So for this particular problem, flushing the cache between edits allowed our client to quickly get their press release out to the major media outlets, which in turn drove more traffic to their website.

 Strategic Caching and Flushing

In some cases, such a surge in traffic can bring down the server. Sometimes the standard Drupal or WordPress caching mechanisms are not enough. While they allow you to selectively flush different types of content, this can be improved upon by using other plug-ins and services, such as CloudFlare.  It offers advanced features such as caching everything to handle a huge surge in visitors to a site. CloudFlare’s standard service caches its users’ content in 14 different locations around the globe, which means even faster access to site content than caching on one’s own server, and it can be highly customized to further boost efficiency.  We were able to increase site performance on infamia.com 40% using CloudFlare and we often install it on client’s servers and configure it for them.

If your site is slow or your hosting company is telling you the load on your server means you should upgrade to a more expensive hosting option, contact us.  We can help to tweak your caching and flushing protocols so that your site runs faster and can handle more visitors without the need to invest in a server upgrade.

Need help optimizing your site? Has caching improved your site’s performance? You can drop us a line, call us at 800.270.5170, or leave a comment below.

Tags:

About Mickey Panayiotakis

Mickey, to date, loves: excellent websites, his boat, snowboarding, awesome new technologies, things sustainable, and eating. The list is necessarily growing: he believes people should love more than they hate. Ernesto, his business partner, and Mickey run Infamia. (Mickey cares about, but does not always love, the oxford comma.)

Trackbacks/Pingbacks

  1. How to Increase Website Performance | Knowmad - August 12, 2013

    […] browser may already have those files cached from another site that also used them. Many CMS’s have caching features built-in, so that once one visitor has requested a dynamic page, like a blog listing, the software […]

Google Analytics Alternative