[Guide] How to Setup W3 Total Cache Plugin?



now i use wprocket, will there be no problem if i switch to w3 total cache? :sweat_smile:


WP Rocket is as good as W3 Total Cache :slight_smile:


It’s subject to test. I found W3TC always better for a general weblog.


Hello Everyone,

This day I want to mark a footprint on my long research for the question I asked here.
Since last few weeks, on one of my site, the concurrent visitor’s starts fluctuating heavily, sometimes they go very high and sometimes they very less.
But, the server resources are nominal, nearly spent 30days on various research activities and finally found the problem with W3TC Plugin (Database Cache).

Yesterday I disabled it and thank god, the site is back to normal today. Always maintaining an average same concurrent visitors and rising today.
A long-term research thus came to an end after various studies…
Still have to work some more…


What will happen if we increase the following values as:
Update Interval: 3600seconds
Pages per interval: 10

@GulshanKumar Need your support.


First thing, I don’t recommend settings up expiry header. Keep it 0.

This way cache will get purge only when it will be required.


I am asking for STEP 26(Refer the image): You have set default value 900 / 10…
I want to know what will happen if we set to 3600 / 10…


You may extend time-period. Nothing will happen.


I found the exact bug, if it’s possible we can discuss via PM.
May be it will be useful for you bro…


I tried to use w3 total cache with this setting. but why my banner ads not showing? I use floating ads :roll_eyes:


Please share your website URL.


I don’t recommend to use preload function of w3tc… if the browser cache expiry is too low. As this value of browser cache expiry also sets the time for Disk Caching on server. So if you are going to set it low then Disk caching and preloading it will be useless and only eat server resources in creating those cache and deleting them quickly.


	function __construct( $config = array() ) {
		parent::__construct( $config );

		$this->_expire = ( isset( $config['expire'] ) ? (int) $config['expire'] : 0 );

		if ( !$this->_expire || $this->_expire > W3TC_CACHE_FILE_EXPIRE_MAX ) {
			$this->_expire = W3TC_CACHE_FILE_EXPIRE_MAX;

by default value of W3TC_CACHE_FILE_EXPIRE_MAX is 30 days
$config[‘expire’] = browser cache expiry time

so according to this code if we set browser cache to 0 or greater than 30 days time then w3tc automatically sets disk caching to 30 days.

Not tested needs research @GulshanKumar

  1. According to me we should set browser cache expiry time to 0
  2. open w3-total-cache-api.php
    and edit W3TC_CACHE_FILE_EXPIRE_MAX time to desired time of expiry of disk cache.
  3. Now set cache control to no-cache , must revalidate.

I just changed the browser cache expire time … things worked perfectly upto 1 day expire time when i tried to set for 5 days then also disk cache was expiring after 1 day… but below 1 day limit it was working according to time specified by w3tc browser cache expire time.

I wish W3tc devs would have given seprate Time setting for Disk Caching.

And I feel no need to preload complete website for just 3600 sec it should be at least 10 hours disk caching.


I also don’t recommend using Preload function of W3TC. Please refer to my point 26.

About expires, I have left everything unchecked. So, expires value 0 doesn’t matter. Please see the point 44. What does it mean? W3TC will only purge only when it is required, for example when we publish post, accept comment, etc. Thanks


On updating content of website w3tc works according to Purge Policy set by user.

But Disk Cache : Enhanced is purged by purge policy and expire time set by user in browser cache expire time field.

when this function returns true then _old tag is attached to cached files. and when new visitor come new cache is created and filename.html_old gets deleted from disk. There is also garbage collector setting in Page cache module that timely clean _old files.

function is_old_file_expired( $file ) {
	$ftime = @filemtime( $file );
	$expire = $this->_expire ? $this->_expire * 5 : W3TC_CACHE_FILE_EXPIRE_MAX;
	if ( $ftime && $ftime < ( time() - $expire ) ) {
		return true;

	return false;

Cleaning function :

function _clean( $path, $remove = false ) {
	$dir = false;
	if ( is_dir( $path ) ) {
		$dir = @opendir( $path );

	if ( $dir ) {
		while ( ( $entry = @readdir( $dir ) ) !== false ) {
			if ( $entry == '.' || $entry == '..' ) {

			$full_path = $path . DIRECTORY_SEPARATOR . $entry;

			if ( substr( $entry, -4 ) === '_old' && !$this->is_old_file_expired( $full_path ) ) {

			foreach ( $this->_exclude as $mask ) {
				if ( fnmatch( $mask, basename( $entry ) ) ) {
					continue 2;

			if ( @is_dir( $full_path ) ) {
				$this->_clean( $full_path );
			} elseif ( substr( $entry, -4 ) === '_old' ) {
				@unlink( $full_path );
			} elseif ( !$this->is_valid( $full_path ) ) {
				$old_entry_path = $full_path . '_old';
				if ( [email protected]( $full_path, $old_entry_path ) ) {
					// if we can delete old entry - do second attempt to store in old-entry file
					if ( @unlink( $old_entry_path ) ) {
						@rename( $full_path, $old_entry_path );

		@closedir( $dir );
		if ( $this->is_empty_dir( $path ) )
			@rmdir( $path );


Yesterday I set expires value to 0, and found w3tc Disk Cache pages are getting expired after approx 10 mins. And this is too less. I wish I could have at least 2 days+ expiry time for server-side page cache. Which I am not able to achieve no matter what settings I change.
I am using Disk Cache Enhanced.

@GulshanKumar @MyilRaj @anon65784627 need suggestions :slight_smile:


@GulshanKumar Should we disable cache preload in ‘Page Cache’ settings?

BTW, I had a question - Is it possible that our sitemap could be cached, and thus affect proper indexing? I mean could it be a case that the site serves a not recently updated cached sitemap to Google?


You can safely disable preload.

Not an issue. For more detail, please contact me in inbox.


please check your inbox my bro,i hope you can help me :grimacing::smiley:


@anon13276939 Before entering CDN path, make sure to check it in the browser https://cdn.example.com either it is working or not. If not, don’t add, fix your CDN pull zone first. Then, try again!


@GulshanKumar W3TC 0.9.7 was released. Any significant improvements/changes that we should be concerned about?