In this tutorial, you will learn the best practices and configuration settings for WP Super Cache, one of the best caching plug-ins for WordPress.
Importance of Caching a WordPress Blog
If you are not yet aware of the importance of caching, take time to read the points below:
1.) WordPress content is driven by PHP. This means all content you see in the browser are served dynamically and generated using PHP.
2.) It is dynamic in the sense that content are being fetched from the MySQL database and sent to the user browser using PHP.
3.) When the server runs a PHP script to fetch the content, it consumes a lot of resources in terms of CPU usage and memory on the server computers. This will be a limiting factor on your website performance especially if you have a high traffic blog.
4.) Caching solves this problem by generating a static HTML file of every WordPress blog post. These static HTML file does not anymore require executing PHP scripts to serve content to your readers.
5.) With caching enabled, things run smoothly and quick on the side of your users. It is because; there is no more complex database communications and script execution. This helps your WordPress blog loads faster in any browser.
6.) With PHP execution operations at a minimum because of caching, you save a lot of precious CPU and memory usage for your WordPress server.
7.) You website can accommodate or serve high level of traffic at lower resource usage.
See the analogy/illustration below:
Optimal Settings for WP Super Cache
One downside of using caching plug-ins in WordPress is that itβs too complicated to understand for any beginning webmaster. One reason of this problem is the lack of understanding of caching mechanism. Well, if you have read the previous information carefully you should have a pretty idea how caching would work.
Another reason is that plug-in developers often provides tons of features to their caching plug-ins and itβs almost impossible to digest or understand all of them even for a novice webmaster. This is true for WordPress Super cache and some caching plug-ins are even more complicated.
To make this very easy for you, recommended optimal settings would be provided. This applies for most blogs that donβt depend on CDN and have enabled mod rewrite modules in their Apache server. This assumes you have fully installed super cache but you have not yet configured it for optimum use. Donβt be confused about mod rewrite or PHP caching you will deal that in the settings below.
The following are some very useful configuration steps. These are the fastest and most efficient WP Super-cache settings:
1.) Login to your WordPress admin panel — Settings β WP Super Cache.
2.) Under βEasyβ make sure βCaching onβ has been checked. By default, PHP caching would be enabled but this is not optimal.
3.) Go to βAdvancedβ, do the following:
a.) Check βCache hits to this website for quick accessβ.
b.) Check βUse mod_rewrite to serve cache filesβ β this requires your blog to have mod rewrite and mod mime modules installed in your server. If you do not know this, send an email to your web host support to confirm that this is enabled on your blog.
c.) Check βDonβt cache pages for known usersβ.
d.) Check βCache Rebuildβ.
e.) Check βMobile Device Supportβ.
f.) Check βExtra homepage checksβ.
4.) Click βUpdate Statusβ button.
5.) You should then see a message:
Rewrite rules must be updated
The rewrite rules required by this plugin have changed or are missing.
To clear this error, scroll down and click βUpdate Mod_Rewrite Rulesβ. You should then see βMod Rewrite Rules Updatedβ. You have successfully enabled mod rewrite caching.
6.) Scroll until you see βRejected User Agentsβ. Delete all entries there and make sure it will be empty. After that click βSave UA stringsβ.
7.) Leave the rest of the settings in the βAdvancedβ section at default settings. Donβt change or checked them unless specified in the above instructions.
8.) Click βContentsβ tab and then click βDelete Cacheβ.
9.) Also click βDelete Expiredβ.
10.) Go to βPreloadβ tab. And put 10080 for values in βRefresh preloaded cache files every ____ minutesβ. This will refresh the super cache once a week and this is recommended if you are writing content at least 3 times to once a week. This setting also works well if you are writing content at least once a month or more.
11.) You need to preload all post as well as check βPreload modeβ.
10.) Click βUpdate Settingsβ.
11.) Click βPreload Cache Nowβ.
12.) WP-Supercache would then create static HTML version of all the posts in your blog and would be kept in the cache directory. These files are served to your blog readers instead of generating everything dynamically using PHP.
Checking for Correct WP Super Cache Implementation
1.) Logout from WordPress admin.
2.) Clear all browser history and cache.
3.) Open new tab in your browser.
4.) Visit your homepage URL.
5.) View the source code and go the last lines of the HTML source code.
6.) You should be able to see these lines (similar to this)
It is important that you see the lines βsuper cacheβ. This implies that the homepage is served from super cache static HTML files. You can try checking your other post HTML source code and it should be cached as well. Try to look at your template to see for template distortion, etc. It should be working well.
If it works well, try enabling Gzip compression by checking βCompress pages…β in advanced settings of WP Supercache. This assumes Gzip compression is not yet enabled for your blog. You can double check it here.
If you see a result βBAD: not using gzip encodingβ, then you can enable gzip encoding in the WP Super cache advanced settings. You need to repeat the test above to make sure the compression is working well for your blog. You can re-check your blog for compression using the tools provided previously.
This time you should see Compression = gzip in the HTML source code footer instead of βsuper cacheβ. Take note that super cache files are being served to your readers with gzip compression.
What if the optimal setting s doesnβt work well for your blog?
You can try the following work around:
1.) Use PHP Caching instead of Mod Rewrite.
2.) Try disabling GZIP compression via WP Super cache and enable it using third party plug-ins.
4.) Report any of the errors by commenting in this post or leaving a comment in the official WP Super cache page here.