Share

If you’re researching this topic for the first time, we recommend starting with our initial article – A Beginner’s Guide. Due to the sheer number of potential server setups out there in the wild, out of necessity, we will be sticking to an overview of some of these advanced options as we dive a little deeper rather than getting into detailed configurations.

In this second part of our overview of the W3 Total Cache (W3TC) plugin, we’re touching on some of the more advanced options available.

Overview

A Summary of The Beginner’s Guide

Let’s begin with a brief recap of what was covered in the beginner’s article.

  • Why use the W3 Total Cache (W3TC) plugin?
  • Requirements and installation.
  • Plugin setup guide and features.
  • Alternative cache plugins.
Plugins

The beginner’s article is an introductory overview of using the W3 Total Cache (W3TC) plugin to enhance website performance. We explain the importance of caching for improving page load speeds and overall user experience, detail the initial setup and installation requirements, and highlight the plugin’s key features. The guide is intended to help new users effectively implement W3TC to optimize their WordPress sites

Page Cache

The Page Cache feature creates static cache files for each page and posts on your website, storing them in the server’s memory or disk (depending on the settings). When a page is requested, the server delivers the pre-generated HTML file instead of processing the heavier WordPress PHP scripts each time. This significantly reduces server load, decreases response times, and can significantly improve speed for websites with high traffic or dynamic content.

Page Cache is highly effective for websites with dynamic or primarily static content, like eCommerce stores, discussion forums, blogs, or news sites, where changes to existing content are only occasionally made.

Basic Settings

Utilizing page cache can significantly enhance your website’s speed, especially when evaluating Time to First Byte (TTFB). TTFB represents the duration between a user accessing your website and your server delivering its initial response.

Here, you enable page caching and choose the page cache method depending on whether you are using a shared server, dedicated/virtual server, or multiple servers.

Page Cache Basic Settings

Advanced Settings

1: General

The options listed on the General Settings page are related to your website’s homepage display settings. Your homepage display settings are managed in the WordPress Dashboard > Settings > Reading section.

General Cache Settings

2: Aliases

The plugin optimizes cache utilization by recognizing alias hostnames, improving website performance and user experience across various domains or subdomains. This is particularly useful when identical WordPress content is accessible from multiple domains, and the cache engine will treat them as equivalent for caching purposes.

Cache Aliases

3: Cache Preload

The option allows for automatically priming the page cache by generating and storing cached versions of web pages without waiting for user requests. Users can set the update interval by determining how frequently a new set of cached pages is generated.

You can limit the number of pages created per batch based on server capabilities. Users can also specify a Sitemap URL to guide the primed cache creation, with pages cached according to XML file priorities.

Cache Preload

4: Purge Policy

This option allows users to specify the pages and feeds to purge when new posts are published, edited, or when comments are submitted to posts on your site. The Purge limit setting allows users to control the number of pages purged on post updates.

Purge Policy

5: Rest API

This option allows you to turn on/off, utilizing the WordPress API to enhance performance and scalability. Turning off the WordPress REST API provides an extra layer of security for users who may not require this functionality.

Enabling caching is recommended, especially when using WordPress as a backend for integrations. It significantly improves response times and reduces resource consumption for repeat API requests, which is particularly beneficial for scaling performance.

WordPress Rest API

6: Expert Advanced

  • Late initialization: With this option turned on, the caching engine postpones the initialization of specific caching processes until later in the page generation cycle. This delay allows for improved compatibility with WordPress functionality, especially when fragment caching is involved. It allows for more effective caching of dynamic elements, enhancing the overall performance and responsiveness of the website.
  • Late caching: This option introduces a mechanism to modify the caching process by postponing the extraction of entries during WordPress’s initialization (‘init’) action. This allows for the overwriting of the key used in the page caching process. This key is a unique identifier associated with a specific page or content, and it is crucial for retrieving the correct cached version. Website admins and developers can leverage this option to tailor the caching strategy based on precise requirements, providing elevated customization and flexibility.
  • Compatibility mode: This setting is designed to enhance the plugin’s interoperability with different hosting environments and address specific actions within the WordPress ecosystem. An example use case for enabling Compatibility Mode addresses issues related to Apache web server rules that sometimes conflict with caching mechanisms.
  • Charset: This option specifically addresses character encoding issues related to UTF-8 support. UTF-8 support correctly handles diverse characters, languages, and symbols on a website. This option might be relevant in situations where the default UTF-8 encoding leads to rendering problems or misinterpretation of characters and provides a means to experiment with alternative character encoding settings to find a configuration that resolves rendering issues.
  • Reject HEAD requests: This option handles HEAD HTTP requests and the associated caching behavior. HEAD is one of the HTTP methods browsers use to request only the headers of a particular resource (e.g., a web page) without requesting the full content. HEAD requests are used to gather information about a resource, such as its size or modification date, without downloading all of the content for performance reasons. Turning on this option ensures that requests made using the HEAD method do not result in the caching of full-page content. This option controls caching behavior and prevents scenarios where subsequent requests for a resource might return empty or incomplete pages.
  • Garbage collection interval: This option controls the frequency at which expired cache data is identified as expired or no longer valid and removed. Lower values are preferable for busy websites with high traffic and frequent content updates. Lower intervals ensure that expired cache data is removed more frequently. High-traffic sites with dynamic content or frequent updates benefit from shorter intervals. In contrast, lower-traffic sites with less dynamic content may not require as frequent garbage collection.
  • Comment cookie lifetime: This option refers to the duration for which comment cookies are deemed valid. Comment cookies are data stored on a user’s machine when they leave a comment on a website. Cookies help recognize the user when they revisit the site. TTL (Time to Live) refers to the duration for which a cookie remains valid. By setting a shorter TTL, the goal is to minimize the duration for which comment cookies are stored on users’ devices where there is a desire to reduce the volume of authenticated user traffic, lowering server load and improving overall server performance.
  • Accepted query strings: This option allows administrators to specify a list of URL parameters that must be cached. The query string is the part that comes after the “?” character and consists of key-value pairs separated by “&” symbols. Query strings are used to pass information to a web page, such as parameters for filtering, sorting, or customizing dynamic. By configuring accepted query strings, administrators have the flexibility to customize the caching behavior for URLs with distinct parameters. Everyday use cases include scenarios where specific parameters dynamically alter the content of a page, such as search results, filter options, or pages with sorting preferences.
  • Rejected user agents: This option allows administrators to specify a list of user agents for which cached pages should not be served. A User Agent is a string of text a browser sends to a web server to identify itself. They provide information about the browser, the browser version, and the device’s operating system that helps adjust content or styles based on the end user’s browser.
  • Rejected cookies: This option allows administrators to specify a list of cookies for which cached pages should not be served and dynamically generates content for each request for users with these defined cookies.
  • Never cache the following pages: This option allows you to define regular expressions for specific pages or directories to be excluded from caching. A regular expression (regex or regexp) is a pattern used to match character combinations in strings. This can be used when certain pages or directories contain dynamic content that should not be cached and typically includes pages with real-time data, user-specific content, or frequently changing information. It is essential to balance caching for performance benefits and serving dynamic content when necessary for specific pages or directories.
  • Never cache pages associated with these categories: This option lets you specify slugs (permalinks) associated with WordPress categories. WordPress content organization uses categories and tags, and each post or page can be related to specific authors or custom fields. You can build a list of slugs (for categories and tags) or usernames (for authors and custom fields) so as not to have cached versions served.
  • Never cache pages that use these tags: This option lets you specify slugs (permalinks) associated with WordPress tags. WordPress content organization uses categories and tags, and each post or page can be associated with specific authors or custom fields. You can build a list of slugs (for categories and tags) or usernames (for authors and custom fields) so as not to have cached versions served.
  • Never cache pages by these authors: This option lets you specify slugs (permalinks) associated with WordPress authors. WordPress content organization uses categories and tags, and each post or page can be associated with specific authors or custom fields. You can build a list of slugs (for categories and tags) or usernames (for authors and custom fields) so as not to have cached versions served.
  • Never cache pages that use these custom fields: This option lets you specify slugs (permalinks) associated with WordPress custom fields. WordPress content organization uses categories and tags, and each post or page can be associated with specific authors or custom fields. You can build a list of slugs (for categories and tags) or usernames (for authors and custom fields) so as not to have cached versions served.
  • Cache exception list: This option lets you override the general rule of not caching certain pages or directories specified in the Never Cache the Following Pages field, and using regular expressions is supported. This is useful when content must be cached, even if it matches exclusion patterns defined for other website areas.
  • Non-trailing slash pages: This option allows you to specify a list of regular expressions for pages without a trailing slash at the end of the URLs that must be cached. Web servers typically treat URLs with or without a trailing slash differently.
  • Specify page headers: This option allows you to extend the caching mechanism beyond the default by including specific HTTP headers and the cached page content. HTTP headers provide essential metadata about the content; for example, specifying Last-Modified can assist in more efficient browser caching and conditional requests.
    • Last-Modified: Indicates the last modification date of the resource.
    • Content-Type: Specifies the media type of the resource.
    • X-Pingback: Indicates the URL where a pingback to the resource should be sent.
    • P3P: Defines a platform for asserting the privacy practices of a website.
    • Link: Specifies relationships between the resource and other resources.
    Each header should be specified on a separate line.
  • Handle XML mime type: This option lets you control how the caching system handles the Content-Type header for XML files, specifying the media type of the resource being served, crucial for proper interpretation by browsers and user agents. This is relevant for websites that include XML files for feeds or sitemaps.

Minify

Minification in web development involves removing unnecessary characters from source code without changing its functionality. This process includes stripping out spaces, line breaks, comments, and block delimiters, which reduces the file size and improves web page load times. Minification optimizes the code to be more efficient for delivery and faster execution on web browsers. This process is commonly applied to CSS, HTML, and JavaScript files, contributing significantly to better performance and faster page rendering.

Minified CSS
An example of minified CSS

Additionally, smaller file sizes mean less bandwidth usage, which can be particularly beneficial for users on slower connections or mobile data. By optimizing a website’s performance, minification also contributes positively to search engine rankings, as search engines favor faster websites.

Basic Settings

The W3 Total Cache Minify option is designed to improve website performance by reducing the size of your website’s CSS, JavaScript (JS), and HTML files. This process can significantly improve web page load times by reducing the amount of data that needs to be downloaded by the user’s browser.

Here, you enable the minify option, select the minify mode, and select the minify cache method depending on whether you use a shared server, dedicated/virtual server, or multiple servers, and the HTML, JS, and CSS minify engine.

Minify Basic Settings

Advanced Settings

1: General

The Rewrite URL Structure option controls how the URLs for CSS and JavaScript (JS) files are structured when embedded in your web pages. When turned on, this setting uses a sophisticated and user-friendly URL structure. However, when turned off, the plugin uses GET variables instead.

The Disable Minify for Logged-in Users option lets you control whether minification should be applied to pages for users logged into the WordPress site. You can also turn on minification error notifications directly to the website Admin and via email.

General Minify Settings

2: HTML & XML

The HTML Minify Settings are intended to reduce the size of HTML files by removing unnecessary characters, whitespace, and comments, ultimately leading to faster page load times.

The Ignored Comment Stems option allows you to selectively preserve specified comments in the HTML, CSS, or JavaScript files during the minification. This option will not remove comments configured by Google Adwords and screen readers by default. In addition, you can add comments to the HTML to remain visible on a new line.

HTML & XML Settings

3: JS

The JS Minify Settings are designed to optimize the loading speed of JavaScript (JS) files on your WordPress website, resulting in faster page load times.

Minify JS Settings

The JS Minify Method option lets you choose how the JavaScript (JS) files should be minified. The minify method you select will impact the organization and delivery of your JS files.

  • Combine & Minify – This method combines multiple JS files into a single file and then minifies the combined file, reducing its overall size and enhancing performance.
  • Minify Only – This method minifies individual JS files without combining them, allowing for more granular control over the optimization process.
  • Combine Only – This method combines multiple JS files into a single file without minifying the combined file, preserving the original formatting and comments in the code. Combining the files reduces the number of HTTP requests made by the browser.

The Minify Engine Settings options are intended to embed minified JavaScript (JS) files within the HTML document. This option controls where the minified JS files should be placed in the HTML—either before the closing tag or after the opening tag. Additionally, it allows you to specify how the scripts are embedded, influencing their loading behavior. The choice of embed type can impact how fast your page loads and renders, depending on the requirements of the scripts.

  • Preserved comment removal (not applied when combine only is active)
  • Line break removal (not safe, not applied when combine only is active)

The HTTP/2 Push option will improve your website’s performance by proactively sending specific resources to the browser before the browser requests them. The primary goal is to expedite the loading of JavaScript files. This is particularly beneficial for critical resources needed for the initial rendering of a page.

4: CSS

The CSS Minify Settings optimizes the loading speed of CSS (Cascading Style Sheets) files by removing unnecessary characters, such as whitespace, comments, and line breaks, leading to faster page load times.

CSS Minify Settings

The CSS Minify Method option lets you choose how the CSS files should be minified without altering the functionality of the styles. The options are:

  • Combine & Minify – This method combines multiple CSS files into a single file and then minifies the combined file, reducing its overall size and enhancing performance.
  • Minify Only – This method minifies individual CSS files without combining them, allowing for more granular control over the optimization process.
  • Combine Only – This method combines multiple CSS files into a single file without minifying the combined file, preserving the original formatting and comments in the code. Combining the files reduces the number of HTTP requests made by the browser.

The Minify Engine Settings control how the minification process is applied to your HTML, CSS, and JavaScript files and is crucial in optimizing the loading speed of your WordPress website.

  • Preserved comment removal (not applied when combine only is active)
  • Line break removal (not applied when combine only is active)

The @import Handling option determines how the code manages imported CSS files using the @import rule in your stylesheets. The @import rule allows you to include external CSS files within a primary CSS file.

The HTTP/2 Push option leverages the capabilities of the HTTP/2 protocol to optimize the delivery of resources on your website by sending specific files to the browser before the browser requests them and reducing latency. HTTP/2 is a modern protocol that improves the efficiency of data transfer between the server and the browser.

5: Expert Advanced

  • Update external files every: This option allows you to specify the interval between downloading and updating external files in the minify cache. This applies to external JavaScript (JS) and CSS files included or referenced in your website but hosted on external servers or Content Delivery Networks (CDNs), contributing to optimal performance and functionality.
  • Garbage collection interval: This option controls the frequency at which expired cache data is identified as expired or no longer valid and removed. Lower values are preferable for busy websites with high traffic and frequent content updates. Lower intervals ensure that expired cache data is removed more frequently. High-traffic sites with dynamic content or frequent updates benefit from shorter intervals. In contrast, lower-traffic sites with less dynamic content may not require as frequent garbage collection.
  • Never minify the following pages: This option lets you specify specific pages that must not be minified.
  • Never minify the following JS files: This option lets you specify specific JavaScript (JS) files that must not be minified. Some JS files may contain code that is sensitive to minification methods.
  • Never minify the following CSS files: This option lets you specify certain Cascading Style Sheets (CSS) files that must not be minified. Some CSS files may contain code that is sensitive to minification methods.
  • Rejected user agents: This option allows administrators to specify a list of user agents for which cached pages should not be served. A User Agent is a string of text a browser sends to a web server to identify itself. They provide information about the browser, the browser version, and the device’s operating system that helps adjust content or styles based on the end user’s browser. 
  • Include external files/libraries: This option allows you to specify external files or libraries that can be combined for optimization, where multiple files are merged into a single file to reduce the number of HTTP requests and improve page loading times overall.
  • Use Regular Expressions for file name matching: This option allows you to use Regular Expressions (regex) when the names of external script files vary and require a more flexible and pattern-based approach to match multiple files with similar characteristics.

Opcode Cache

Opcode cache is a powerful W3TC feature that enhances the performance of a WordPress website by caching compiled PHP code. The use of Opcode in the PHP execution process facilitates a more efficient and scalable approach to script execution, reduces server load, improves response times, and ultimately enhances the overall speed and responsiveness of your WordPress site.

Opcode Cache

By storing pre-compiled code in memory, Opcode cache eliminates the need for repetitive interpretation and compilation of PHP files.

Database Cache

WordPress Database Caching, or Object Caching, is a method used to improve website performance by storing the results of database queries in the cache to reduce latency and increase throughput for read-heavy applications like WordPress. When a web page is requested, WordPress queries its database to retrieve the data, which can be time-consuming, mainly when complex queries or high traffic are used.

Database caching helps reduce the load on the database by saving the results of these queries. When the same data is requested again, it can be fetched from the cache instead of the database, leading to faster page load times and reduced server load. W3 Total Cache’s installation guidelines indicate that enabling this option on shared hosting setups may actually be counterproductive. We suggest testing your setup in isolation to judge its effectiveness.

The types of performance gains on offer will depend on the complexities of your setup. The main distinction is whether the information is stored on disk or in memory with a solution such as APC or Memcached. The common consensus is that in-memory solutions provide the best results for the database cache.

Basic Settings

This option is turned on by default, mimicking the default WordPress behavior. It excludes logged-in users from the cache, and user activity requests bypass the database cache. Logged-in users might change information, such as post authors publishing updates on a post or a site member updating their profile.

Database Cache Basic Settings

Advanced Settings

In the context of software or online platforms like WordPress plugins, Expert Advanced Settings refer to configurable options intended for users with advanced knowledge or specific technical expertise. These settings allow for granular control over the W3TC plugin functions, allowing you to fine-tune performance, security, and behavior better than basic settings. You can manipulate caching behaviors, database interactions, and fine-tuning performance metrics, among other technical aspects.

1: Expert Advanced

  • Maximum lifetime of cache objects: This option allows you to determine how long cached data must remain stored in memory before being considered outdated. A longer lifetime (in seconds) improves performance by serving cached content faster, reducing database queries and server load. For high-traffic websites with frequent changes to content, a shorter lifetime is recommended. A longer lifetime (in seconds) could suffice for low traffic with less frequent changes to content.
  • Garbage collection interval: This option controls the frequency at which expired cache data is identified as expired or no longer valid and removed. Lower values are preferable for busy websites with high traffic and frequent content updates. Lower intervals ensure that expired cache data is removed more frequently. High-traffic sites with dynamic content or frequent updates benefit from shorter intervals. In contrast, lower-traffic sites with less dynamic content may not require as frequent garbage collection.
  • Never cache the following pages: This option excludes specific pages or URLs from being stored in the database cache, allowing data to be retrieved directly from the database on every request. Dynamic pages with continually changing content, like user account information and shopping carts, should not be cached.
  • Ignored query stems: This option lets you specify exact sections of database queries that must not be cached. SQL queries containing these stems will always bypass the cache and retrieve data directly from the database, even if other parts of the query are eligible for caching.
  • Reject query words: This option lets you block caching based on specified words or patterns anywhere within a SQL query. Any query containing specific words, regardless of context or surrounding elements, will bypass the cache and retrieve data directly from the database. This is helpful when preventing caching of search results pages (for example) to guarantee users always see the latest results.
  • Reject constants: This option lets you prevent caching of any query containing specific constant values. The constant value could be a number, a string of text, or data included directly within a SQL query.

Object Cache

WordPress ships with several Object Caching options built-in for developers to access and use. Object Caching in the context of web performance, particularly with WordPress, refers to storing frequently accessed query results or computational data in memory to reduce the time required for these items to be computed or fetched from the database. This type of caching can significantly improve performance by decreasing the load on the database and speeding up the page-loading process, as the data is readily available in the cache rather than being recalculated or retrieved on each page request.

Basic Settings

Enabling Object Cache is particularly beneficial for websites with heavy database usage or high traffic volumes, as it helps alleviate the strain on the server by efficiently serving cached data.

Object Cache

Advanced Settings

These advanced settings allow for granular control over the W3TC plugin functions, allowing you to fine-tune cache performance and overall website behavior. You can manipulate caching and database interactions and refine cache performance metrics. 

1: Expert Advanced

  • Maximum lifetime of cache objects: This option allows you to determine how long cached data must remain stored in memory before being considered outdated. A longer lifetime (in seconds) improves performance by serving cached content faster, reducing database queries and server load. For high-traffic websites with frequent changes to content, a shorter lifetime is recommended. A longer lifetime (in seconds) could suffice for low traffic with less frequent changes to content.
  • Garbage collection interval: This option controls the frequency at which expired cache data is identified as expired or no longer valid and removed. Lower values are preferable for busy websites with high traffic and frequent content updates. Lower intervals ensure that expired cache data is removed more frequently. High-traffic sites with dynamic content or frequent updates benefit from shorter intervals. In contrast, lower-traffic sites with less dynamic content may not require as frequent garbage collection.
  • Never cache the following pages: This option excludes specific pages or URLs from being stored in the database cache, allowing data to be retrieved directly from the database on every request. Dynamic pages with continually changing content, like user account information and shopping carts, should not be cached.
  • Ignored query stems: This option lets you specify exact sections of database queries that must not be cached. SQL queries containing these stems will always bypass the cache and retrieve data directly from the database, even if other parts of the query are eligible for caching.
  • Reject query words: This option lets you block caching based on specified words or patterns anywhere within a SQL query. Any query containing specific words, regardless of context or surrounding elements, will bypass the cache and retrieve data directly from the database. This is helpful when preventing caching of search results pages (for example) to guarantee users always see the latest results.
  • Reject constants: This option lets you prevent caching of any query containing specific constant values. The constant value could be a number, a string of text, or data included directly within a SQL query.

Content Delivery Networks (CDN)

Using a CDN (Content Delivery Network) means offloading the delivery of a certain subset of your content to a company that specializes in getting that content to the user as quickly as possible, regardless of where they are in the world.

They do this by having numerous data centers located strategically around the globe where your content is mirrored and delivered to the user from the location nearest to them.

In the case of WordPress, this would typically involve the delivery of static assets such as image files along with CSS and Javascript files.

CloudFlare and MaxCDN are two of the best known providers in the business and both offer user friendly options for those just starting to get their feet wet with CDNs.

In terms of the backend of W3 Total Cache, there are three general areas to configure in Performance > CDN. Firstly, you need to decide which types of content you will be offloading to the CDN in the General options.

Secondly, you need to establish the connection with the CDN itself via the Configuration panel.

Options here will naturally vary from provider to provider but the good folks over at WPBeginner have an excellent breakdown of how to install MaxCDN with W3 Total Cache that should give you a good idea of the overall process.

The default Advanced settings should work out of the box on most setups, so begin there before starting to tweak.

W3TC Resources And Showcase

Many blue-chip companies trust the W3 Total Cache plugin for their websites. Along with Frederick Townes’ work for Mashable, high-profile sites such as yoast.com, ilovetypography.com, smashingmagazine.com, and Matt Cutts have all plumped for this plugin as their caching solution in the past.

Resources

As you explore W3 Total Cache further, it’s worth bookmarking a few references for general information and troubleshooting purposes:

  • W3 Total Cache plugin homepage: The Installation and FAQ tabs here address many common issues users run into. Make sure you review them both carefully. You can also access the support forums from this page.

  • W3 Edge FAQ: This set of FAQs provides a little more detail, including coverage of technical questions such as, for example, whether to choose opcode caching or memcached. It’s well worth a detailed read before you start integrating on your own site.
  • Stack Exchange: As always, Stack Exchange and Stack Overflow are likely to be your friend at some stage.

Showcase

The following links provide some more detailed breakdowns of real-world W3 Total Cache performance that you might find useful when digging deeper into how best to implement it on your own site:

  • MyBloggingThing: A good overview of how W3 Total Cache can fit into an overall optimization strategy.

  • DashboardJunkie: An excellent deep-dive comparison of real-world W3 Total Cache performance as measured against other popular caching solutions.

Summary

We hope the points above will shed further light on some of the more advanced features of W3 Total Cache and help you make the most of it within the parameters of your own particular setup. Two takeaways:

  • If you’re managing your own servers – virtual or dedicated – database and object caching both stand to bring major performance increases.

  • Minification and using a Content Delivery Network are options available to all and should bring significant gains to both you and your users.

Subscribe To Our Newsletter

Receive all of the latest news and updates fresh from ThemeFusion!

Leave a comment