[Guide] How to Setup W3 Total Cache Plugin?

dailydose

#63

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


#64

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


#65

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


#66

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…


#67

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

@gulshankumar Need your support.


#68

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.


#69

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…


#70

You may extend time-period. Nothing will happen.


#71

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


#72

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


#73

Please share your website URL.


#74

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.

Cache_File_Generic.php

	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.

Tested
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.


#75

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


#76

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 == '..' ) {
				continue;
			}

			$full_path = $path . DIRECTORY_SEPARATOR . $entry;

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

			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' ) {
				$this->processed_count++;
				@unlink( $full_path );
			} elseif ( !$this->is_valid( $full_path ) ) {
				$old_entry_path = $full_path . '_old';
				$this->processed_count++;
				if ( !@rename( $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 );
	}
}

#77

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:


#78

@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?


#79

You can safely disable preload.

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


#80

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


#82

@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!


#84

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