Basic W3TC Caching Tutorial – Caching Support Added To SDU

Initial testing of default WordPress installations do not generally fair well on a performance index test. This means that even on simple websites, adding cache support to your blog can make a considerable difference to the overall blog performance.

In order to test the performance of sites that are implementing caching plugins we recommend using GTMetrix.com.

This site let’s you test the sites performance basics for free and provides a wealth of information relating to how to fix these issues.

Here is the performance report before we installed any form of site caching plugins.

Shadow Dragon Unlimited Site Performance: Before Caching

http://gtmetrix.com/reports/shadowdragonunlimited.com/qC9A0XIx

The two options we look at most are Page Speed and YSLow Ratings. These two pages account for enough information to provide a decent overall indication of how well a website will do. The higher the grade for these two sections means the better your site will perform. Even Google has suggested that site performance may help rankings.

Even if Google did not care about site performance the people reading the site sure do. I hate nothing more then sites that do not load at a reasonable clip. We understand that even the best sites can slow down due to many issues, such as where it’s hosted, the overall network conditions and any number of other issues.

In this case, adding a caching plugin has helped considerably.

A few weeks back we implemented a test cache function via htaccess rules. Those rules were preliminary just to account for slight increases of traffic as we began developing the website. In order to test properly we did not make any active promotions for traffic to the site.

Page load times hovered around the 3 second range for the next few weeks. As seen on this report from the middle of the month:

Shadow Dragon Unlimited Performance Report: Basic caching

http://gtmetrix.com/reports/shadowdragonunlimited.com/IZPVV6Er

After a few weeks at this level we decided to see exactly what might happen if we ramped up the site a little. In all, we posted several new posts this week. Making sure that these sites were also shared socially around the web by pushing them out to social sites such as Facebook, Twitter, and StumbleUpon we waited patiently to see if we could break the site.

Well, we did.

500 Server error at SDU

Today we encountered those dreaded 500 errors I often see when a website manages to spike in traffic enough to cause problems. We knew it might happen but were unsure of whether it would happen this week.

Implementing Cache Plugins

Tonight we setup and installed our caching plugin of choice, the W3 Total Cache plugin. While many people may feel this plugin is not the newest or latest and greatest we like how well it works. Once you have installed it a couple times it becomes pretty easily setup in about 5-10 minutes.

Here is the performance report just after installation of W3TC:

Shadow Dragon Unlimited Performance Report: W3TC installed but not configured

http://gtmetrix.com/reports/shadowdragonunlimited.com/BpjhoKLu

The times on the page loads went down to under 2 seconds and had letter grades that went from E to B. This without even turning on any of the actual caching options that are installed.

The only “default” cache option that W3TC installs on plugin activation is the Browser caching option. Which as you can see made a difference, but we knew it could be even better.

Here are the settings we chose to use for standard installations of W3TC:

W3 Total Cache Settings:

  • General Page:
    • Page Cache: Enabled
    • Minify: Enabled
    • Database Cache: Enabled
    • Object Cache: Enabled
    • Browser Cache: Enabled

Once you enable these settings click “Save All”.

Just use the default settings on the General page for each section as these are selected based on your servers capabilities. The other sections not mentioned such as CDN are for advanced installation which will be covered at a later time.

Once the settings have been saved you can then check the separate page settings for these sections and tweak the individual settings for these caching types.

 

Page Cache Settings:

General Section:


For many blogs this is your most visited page, it is recommended that you cache it.

Even if using a feed proxy service (like FeedBurner), enabling this option is still recommended.

Cache SSL requests (uniquely) for improved performance.

Search result (and similar) pages will be cached if enabled.

Reduce server load by caching 404 pages. If the disk enhanced method of disk caching is used, 404 pages will be returned with a 200 response code. Use at your own risk.

Cache only requests with the same URL as the site’s site address.

Unauthenticated users may view a cached version of the last authenticated user’s view of a given page. Disabling this option is not recommended.

Select user roles that should not receive cached pages:

         

Cache Preload:

 seconds
The number of seconds to wait before creating another set of cached pages.

Limit the number of pages to create per batch. Fewer pages may be better for under-powered servers.

compliant sitemap can be used to specify the pages to maintain in the primed cache. Pages will be cached according to the priorities specified in the XML file. Due to its completeness and integrations, WordPress SEO is recommended for use with this feature.

Tweak the settings in the above two sections and leave the rest of teh sections as default and save your options. Make sure to put your sites “sitemap feed” into the preload section. If you do not have a sitemap being created for your site then consider using the Google Sitemap Generator.

Please check the settings that are right for you, for instance we do not worry about caching logged in users as the only users we have that login are staff members who can refresh the cache as needed.

 

Minify Page Settings: 

General:


If disabled, CSS and JS embeddings will use GET variables instead of “fancy” links.

Authenticated users will not receive minified pages if this option is enabled.
Admin Notification

Email Notification

Both Admin & Email Notification

Notify when minify cache creation errors occur.

HTML & XML Section:

HTML minify settings:



Everything also on this page we left as default. Save your options and move to the next page.

 

Database Cache Page:

The Database Cache only gets one adjustment if needed at this point:


Enabling this option is recommended to maintain default WordPress behavior.

Save all settings and move to next page.

 

Object Cache Page:

Defaults are fine for basic setup.

Move to next page.

 

Browser Cache Page:

This page will have a few options that you can tweak. This is a little bit of trial and error and personal preference. In most cases we enable those settings that will help improve general performance as seen below:

General Section:

Specify global browser cache policy.


Set the Last-Modified header to enable 304 Not Modified response.

Set the expires header to encourage browser caching of files.

Set pragma and cache-control headers to encourage browser caching of files.

Set the Etag header to encourage browser caching of files.

Set this header to assist in identifying optimized files.

Reduce the download time for text-based files.

Removes Set-Cookie header for responses.

Reduce server load by allowing the web server to handle 404 (not found) errors for static files (images etc).

CSS & JS Section:

Specify browser cache policy for Cascading Style Sheets and JavaScript files.


Set the Last-Modified header to enable 304 Not Modified response.

Set the expires header to encourage browser caching of files.
 seconds

Set pragma and cache-control headers to encourage browser caching of files.
cache with max-age (“public, max-age=EXPIRES_SECONDS”)

cache with validation (“public, must-revalidate, proxy-revalidate”

cache with max-age and validation (“max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate”)

cache without proxy (“private, must-revalidate”)

no-cache (“max-age=0, private, no-store, no-cache, must-revalidate”


Set the Etag header to encourage browser caching of files.

Set this header to assist in identifying optimized files.

Reduce the download time for text-based files.

Whenever settings are changed, a new query string will be generated and appended to objects allowing the new policy to be applied.

Removes Set-Cookie header for responses.

 

HTML & XML Section:

Specify browser cache policy for posts, pages, feeds and text-based files.


Set the Last-Modified header to enable 304 Not Modified response.

Set the expires header to encourage browser caching of files.
 seconds

Set pragma and cache-control headers to encourage browser caching of files.
cache with max-age (“public, max-age=EXPIRES_SECONDS”)

cache with validation (“public, must-revalidate, proxy-revalidate”)

cache with max-age and validation (“max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate”)

cache without proxy (“private, must-revalidate”)

no-cache (“max-age=0, private, no-store, no-cache, must-revalidate”)


Set the Etag header to encourage browser caching of files.

Set this header to assist in identifying optimized files.

Reduce the download time for text-based files.

Media Section:


Set the Last-Modified header to enable 304 Not Modified response.

Set the expires header to encourage browser caching of files.
 seconds

Set pragma and cache-control headers to encourage browser caching of files.
cache with max-age (“public, max-age=EXPIRES_SECONDS”)

cache with validation (“public, must-revalidate, proxy-revalidate”)

cache with max-age and validation (“max-age=EXPIRES_SECONDS, public, must-revalidate, proxy-revalidate”)

cache without proxy (“private, must-revalidate”)

no-cache (“max-age=0, private, no-store, no-cache, must-revalidate”)


Set the Etag header to encourage browser caching of files.

Set this header to assist in identifying optimized files.

Reduce the download time for text-based files.

Whenever settings are changed, a new query string will be generated and appended to objects allowing the new policy to be applied.

Removes Set-Cookie header for responses.

Many of the sections with the exception of the General section will likely be defaults. That is ok.

Save all settings and your pretty much done with a basic W3 Total Cache installation.

 

That has been a basic installation of W3 Total Cache plugin. These settings are in many cases the default values for some sections or are based upon the plugins own determination of what your server can handle.

Many users complain that this cannot work on shared hosting, but in fact it can. If you set it up properly. We often tweak the timings depending upon how quickly a site is updated.

Sites with less updates can hold the cache files much longer then busy sites. These are up to you to fine tune as your site grows and becomes more active.

Additional features like CDN usage and faster caching options using MemCache are more specific to an advanced setup, such as being on a VPS or dedicated server. The CDN, while it can be used even with shared hosting is often an extra cost so it is not normally implemented on a basic installation. Again, this is up to your own personal preference.

Below is the last report we generated from GTMetrix:

Shadow Dragon Unlimited Performance Report: W3TC Installed and Configured

http://gtmetrix.com/reports/shadowdragonunlimited.com/AHYOvEY9

This gave us an fastest page load time of .17 seconds and an average page load time under 2 seconds. This was enough to push both our grade scores into the A range. Even so, this was only at a 92% value with additional tweaks that could be implemented such as additional image compression.

Adding a CDN to the mix would bring the performance levels even higher but we will save that for another time.

If you’re using WordPress and your site gets any decent amount of traffic make sure to consider using a caching plugin. While we recommend W3TC for sites that we use, we do also understand that newer caching plugins are out there and you should at least think about using something. Just make sure to use a site like GTMetrix to help determine exactly what any caching plugin you choose is truly helping you to accomplish.