How To Configure WP Super Cache

Best Config setup for your WP super Cache

Last update:

In this post, we show you how we configure WP Super Cache to serve the pages of your WordPress website at maximum speed. We will leave aside the basics and focus on the key features that we use at Wetopi as a Specialized WordPress Managed Hosting.

Table of Contents

Why WP SuperCache?

WP Super Cache is the cache plugin that we at Wetopi (Specialized WordPress Managed Hosting) always recommend for multiple reasons:

  • It’s lightweight, and although it may seem complex, it focuses on a single purpose: generating static HTML.
  • It has a very good reputation and a history of millions of downloads.
  • It is maintained by Automattic, and is open source. This is their Github repository.
  • As it is a classic, almost all plugins correctly handle exceptions when it is necessary to avoid cache systems.
  • It rarely causes incompatibilities with other plugins.

Activate and configure WP Super Cache with 1-click

If your server is hosted at Wetopi, installing, enabling and configuring WP Super Cache is a simple click.

You will find this option in the menu of your WordPress server, within the advanced options section:

Optimized WP Super Cache setup with one click
Click on WP Super Cache to install, activate and optimally configure the cache system

No further action is required.

If you are not hosted on Wetopi, or want to know the combination of options that we consider optimal to configure WP Super Cache, continue reading the article below.

Do not break your production site!
Staging environments are the solution!

Clone to a staging environment to test and fix any HTTP error code.
To clone a WordPress site with Wetopi is as easy as a simple click.

The best way to serve cached pages

WP Super Cache offers two methods to cache pages:

  • simple and
  • Expert
Configure WP Super Cache in expert mode
Set WP Super Cache in expert mode for optimal performance

With the “Simple” option, PHP is used to serve cached pages, while with the “Expert” method, cached pages are served directly without using PHP.

Web servers are capable of serving HTML static pages very efficiently.

Skip the PHP processor and serve static cached pages.

How to directly serve the static cached pages

At Wetopi, to maximize speed, we use Nginx as the web page server. A virtue of Nginx is that it is tremendously efficient when it comes to serving statics: images, JS, CSS, HTML, etc.

In order for Nginx to serve the cache files bypassing the PHP processor, we add the following code to our nginx.conf configuration file:

set $cache_uri $request_uri;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
    set $cache_uri 'null cache';
}

if ($query_string != "") {
    set $cache_uri 'null cache';
}

# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
    set $cache_uri 'null cache';
}

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
    set $cache_uri 'null cache';
}


location / {
    include  /var/www/conf/mime.types;

    # No php is touched for static content.
    # include the "?$args" part so non-default permalinks doesn't break when using query string
    try_files /wp-content/cache/supercache/$http_host/$cache_uri/index-https.html $uri $uri/ /index.php?$args;
}

NOTE: We assume that the web is being served with HTTPS.
If not, modify the try_files by removing the ” -https ” suffix.

IMPORTANT: With Wetopi, you do not need to manually modify Nginx configuration files. This Nginx settings are automatically turned ON and OFF with the WP Super Cache option you have in your panel.

Compress the pages the right way

Compressing the files of your WordPress website is an excellent way to reduce the size of the pages and resources that have text: HTML, Javascript code, CSS style sheets, …

With compression we will be able to speed up the loading time.

WP Super Cache and most plugins have advanced options for this task.

However, if you have a modern web server, we strongly recommend to:
DO NOT use compression options managed by plugins.

Modern web servers perform better than PHP when doing this task.

Do not compress pages with WP Super Cache, or any other plugin that does such a task with the help of PHP. Instead, use a good web server with the ability to compress efficiently.

Configure WP Super Cache to Do not compress pages
Do not check the Compress pages option.

From Wetopi we recommend a web server capable of compressing using Brotli.

Brotli is the replacement for traditional compression systems like gzip. In this article you will find detailed information about Brotli compression for WordPress.

With Wetopi you get FREE Development Servers, Brotli ready,
and finely tuned to serve WordPress at lighting speed.

Signup in 10 seconds and get your free wetopi account

We can see how the compressed pages are served using the inspector of our browser. Hovering over the value of the page size, a floating text appears where it indicating 18.3 kB transferred from a resource of size 98.4 kB. That difference tells us that our web server is compressing our resources:

Using a web server with compression enabled
18.3 kB transferred over the network, resource size 98.4 kB

It is not always necessary to minimize resources

If we want a fast WordPress, we need to remove any unnecessary plugins or tasks. Many caching plugins are overloaded with options that are not always necessary. Among them, Minification (minimizing resources).

Apparently it seems counterintuitive: will minify make the file smaller and thus make my WordPress run faster? Nope?

Well yes and no!

It will go faster if you don’t have a good compression system as we mentioned in the previous point. But it won’t make much sense if you have a server with a good compression system.

As a test, below we minimize the html page with the Autoptimize plugin:

Minimized html page with Autoptimize plugin
This is what a minified html page looks like.

And if we look at the reduction in the size of the HTML file when we serve it in a compressed form, the difference should be minimal:

17.7 kB transferred over the network, resource size 92.2 kB

We have a minimal improvement, reducing the “Size” from 18.3 to 17.7 kB that in “Time” gets translated to 2 milli-seconds.

In such a case, it is preferable to release WordPress from the minification task. Minimizing is a really expensive process in processing time. It is better to offload the CPU so that the generation of pages in WordPress is much faster. Either when we do “Prefetch” to save all pages in cache, or when we serve faster to users who view uncached pages.

Another important aspect to keep in mind is that most themes use javascript resources already by default in their minified format.

Our opinion:

Let’s not rule out a plugin like WP Super Cache, because it doesn’t have options like Minification.

It is much better to have a good compression system at the web server level.

How long to cache pages?

The quick answer is: as long as possible.

By default our Wetopi WP Super Cache config is set to an Expiry Time of 48h (172800 seconds). For the “Garbage Collection”, or cache cleaning we set the Timer to 9 minutes (540 seconds). To avoid peak workloads on your server, it is important that the cleaning is done little by little, so you will avoid accumulating massive file manipulation tasks.

How to configure Wp Super Cache Expiration Time and Garbage Collection
Wp Super Cache file cleanup and permanence settings

If you have a website where the content is controlled by your team and it only changes when editing posts or pages, then you can leave the HTML generated pages in cache indefinitely (Put a 0 to disable Garbage Collection).

By default,
when saving changes to a Post or Page
Wp Super Cache is already in charge of regenerating the page cache.

If you have a website with many references or dependencies between pages or posts, you can configure WP Super Cache with the option: “Clear all cache files when a post or page is published or updated”:

Clear all cache files when a post or page is published or updated

WP Super Cache Settings for WooCommerce

By combining WooCommerce with WP Super Cache there is usually no problem with pages displaying personalized information for the user. WooCommerce is compatible with WP Super Cache, by default you don’t have to set additional settings.

When working with WooCommerce, it is important that pages like the cart /cart/, /mi-cuenta/, or /checkout/ are never cached. However, since version 1.4.2, WooCommerce sets the DONOTCACHEPAGE constant, which means that technically you don’t need to do anything to exclude pages from the system cache.

However, it is always advisable to test the different routes of a purchase:

  • Test that the product page loads and displays the correct products.
  • Test that your category pages load and display the correct products.
  • Make a purchase without registering, as a guest. Make sure that the payment process works, and that the details of the purchase are correct.
  • Make a purchase by logging in as a customer. Make sure that the payment process works, and that the details of the purchase are correct.
  • Create a coupon and try to use it at checkout. Make sure the coupon is applied and that the amount in the cart and the price paid are correct.
  • Try to reset your password and make sure everything is working properly.

Running Google Ads campaigns with WP Super Cache

By launching an advertising campaign, we generate significant traffic spikes. In situations like this we need a good caching system, more than ever.

Dealing with cache and URL campaign tracking parameters

In order to track campaign conversions, Google, Facebook, Instagram, etc., the consensus is to pass the campaign references as parameters in the URL. For example:

https://wetopi.com/?utm_source=google&utm_medium=ppc&account=usa&utm_campaign=Search&utm_term=managed%20hosting

The Problem: The web page is always the same and we are interested in serving it fast from the cache, but tracking parameters such as utm_term change depending on the search words. The result can be thousands of different URLs for the same page.

For your Ad Campaign, do not let WP Super Cache consider different each and every one of the URLs that point to the same page.

It is just the opposite of what is desired: you would not recycle the cache calls and you would give WordPress a lot of work generating a static version for each of the URLs.

The solution is simple, in the advanced options of WP Super Cache, you’ll find a section named “Tracking Parameters” where you can define all the tracking parameters you want to ignore in the URLs:

Define the tracking parameters to Ignore in the URLs
Activate this advanced option so that WP Super Cache ignores these parameters and always serves the same page.

We are techies passionate about WordPress. With wetopi, a Managed WordPress Hosting, we want to minimize the friction that every professional faces when working and hosting WordPress projects.

Not a wetopi user?

Free full performance servers for your development and test.
No credit card required.

This might also interest you

See how Wetopi stacks up against your current hosting

Try before you buy.

With no obligation on your part, we’ll migrate a copy of your website:

No hidden small text.
No commitments.
No credit card.