<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>w3 total cache Archives - Chris Gilligan » new media</title>
	<atom:link href="http://chrisgilligan.com/tag/w3-total-cache/feed/" rel="self" type="application/rss+xml" />
	<link>https://chrisgilligan.com/tag/w3-total-cache/</link>
	<description>portfolio of web work</description>
	<lastBuildDate>Fri, 01 Feb 2013 18:46:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>Varnish VCL and Config for WordPress with W3 Total Cache</title>
		<link>https://chrisgilligan.com/consulting/varnish-vcl-and-config-for-wordpress-with-w3-total-cache/</link>
					<comments>https://chrisgilligan.com/consulting/varnish-vcl-and-config-for-wordpress-with-w3-total-cache/#comments</comments>
		
		<dc:creator><![CDATA[Chris Gilligan]]></dc:creator>
		<pubDate>Wed, 15 Aug 2012 00:23:11 +0000</pubDate>
				<category><![CDATA[Amazon Web Services]]></category>
		<category><![CDATA[Consulting]]></category>
		<category><![CDATA[Content Management Systems]]></category>
		<category><![CDATA[Web Server Performance Tuning]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[apc cache]]></category>
		<category><![CDATA[apc fcgid]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[varnish]]></category>
		<category><![CDATA[varnish cache]]></category>
		<category><![CDATA[w3 total cache]]></category>
		<category><![CDATA[w3tc]]></category>
		<guid isPermaLink="false">https://chrisgilligan.com/?p=867</guid>

					<description><![CDATA[<p>I have been working on a Varnish front-end for Apache, to be used with WordPress sites. I described the architecture in Load Balancing Virtualmin WordPress Hosting Server with Varnish on AWS. I now have a configuration that seems to work for all WordPress features, including logged-out commenting. This configuration also works well with W3 Total [&#8230;]</p>
<p>The post <a href="https://chrisgilligan.com/consulting/varnish-vcl-and-config-for-wordpress-with-w3-total-cache/">Varnish VCL and Config for WordPress with W3 Total Cache</a> appeared first on <a href="https://chrisgilligan.com">Chris Gilligan » new media</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="float: right; margin: 0 0 10px 15px; width:240px; height: auto;">
		<img src="https://d2lehxir4n36oh.cloudfront.net/wp-content/uploads/2012/08/wordnish.png?x25141" width="240" style="max-width: 100%; height: auto;" />
		</p><p>I have been working on a Varnish front-end for Apache, to be used with WordPress sites. I described the architecture in <a title="Load Balancing Virtualmin WordPress Hosting Server with Varnish on AWS" href="https://chrisgilligan.com/consulting/load-balancing-virtualmin-wordpress-hosting-server-varnish-aws/">Load Balancing Virtualmin WordPress Hosting Server with Varnish on AWS</a>. I now have a configuration that seems to work for all WordPress features, including logged-out commenting. This configuration also works well with W3 Total Cache.</p>
<p>This configuration is for Varnish on a separate server, but should also work on a single server with appropriate changes to the port and backend IP settings.</p>
<h3>Varnish Config (/etc/sysconfig/varnish)</h3>
<pre class="lang:perl decode:true crayon-selected"># Configuration file for varnish
#
# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this
# shell script fragment.
#
#
# Maximum number of open files (for ulimit -n)
NFILES=131072
#
# Locked shared memory (for ulimit -l)
# Default log size is 82MB + header
MEMLOCK=82000
#
# Maximum size of corefile (for ulimit -c). Default in Fedora is 0
# DAEMON_COREFILE_LIMIT="unlimited"
#
# Set this to 1 to make init script reload try to switch vcl without restart.
# To make this work, you need to set the following variables
# explicit: VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_ADDRESS,
# VARNISH_ADMIN_LISTEN_PORT, VARNISH_SECRET_FILE
RELOAD_VCL=1
#
## Advanced configuration
#
# # Main configuration file.
VARNISH_VCL_CONF=/etc/varnish/wordpress-varnish3.vcl
#
# # Default address and port to bind to
# # Blank address means all IPv4 and IPv6 interfaces, otherwise specify
# # a host name, an IPv4 dotted quad, or an IPv6 address in brackets.
# VARNISH_LISTEN_ADDRESS=
VARNISH_LISTEN_PORT=80
#
# # Telnet admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082
#
# # Shared secret file for admin interface
VARNISH_SECRET_FILE=/etc/varnish/secret
#
# # The minimum number of worker threads to start
VARNISH_MIN_THREADS=1
#
# # The Maximum number of worker threads to start
VARNISH_MAX_THREADS=1000
#
# # Idle timeout for worker threads
VARNISH_THREAD_TIMEOUT=120
#
# # Cache file location if using file cache
#VARNISH_STORAGE_FILE=/var/lib/varnish/varnish_storage.bin
#
# # Cache size: in bytes, optionally using k / M / G / T suffix,
# # or in percentage of available disk space using the % suffix.
VARNISH_STORAGE_SIZE=3G
#
# # Backend storage specification
# malloc runs from RAM, file from file
VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}"
#VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"
#
# # Default TTL used when the backend does not specify one
VARNISH_TTL=120
#
# # DAEMON_OPTS is used by the init script. If you add or remove options,
# # be sure you update this section, too.
DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \
-f ${VARNISH_VCL_CONF} \
-T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \
-t ${VARNISH_TTL} \
-w ${VARNISH_MIN_THREADS},${VARNISH_MAX_THREADS},${VARNISH_THREAD_TIMEOUT} \
-u varnish -g varnish \
-S ${VARNISH_SECRET_FILE} \
-s ${VARNISH_STORAGE}"
#</pre>
<h3>Varnish VCL (/etc/varnish/wordpress-varnish3.vcl)</h3>
<pre class="lang:default decode:true">backend origin {
.host = "10.11.12.13";
.port = "80";
.connect_timeout = 60s;
.first_byte_timeout = 60s;
.between_bytes_timeout = 60s;
}
#
sub vcl_recv {
# only using one backend
set req.backend = origin;
#
# set standard proxied ip header for getting original remote address
set req.http.X-Forwarded-For = client.ip;
#
# logged in users must always pass
if( req.url ~ "^/wp-(login|admin)" || req.http.Cookie ~ "wordpress_logged_in_" ){
return (pass);
}
# accept purges from w3tc and varnish http purge
if (req.request == "PURGE") {
return (lookup);
}
#
# don't cache search results
if( req.url ~ "\?s=" ){
return (pass);
}
#
# always pass through posted requests and those with basic auth
if ( req.request == "POST" || req.http.Authorization ) {
return (pass);
}
#
# else ok to fetch a cached page
unset req.http.Cookie;
return (lookup);
}
#
# accept purges from w3tc and varnish http purge
sub vcl_hit {
if (req.request == "PURGE") { purge; }
return (deliver);
}
#
# accept purges from w3tc and varnish http purge
sub vcl_miss {
if (req.request == "PURGE") { purge; }
return (fetch);
}
#
sub vcl_fetch {
#
# remove some headers we never want to see
unset beresp.http.Server;
unset beresp.http.X-Powered-By;
#
# only allow cookies to be set if we're in admin area - i.e. commenters stay logged out
if( beresp.http.Set-Cookie &amp;&amp; req.url !~ "^/wp-(login|admin)" ){
unset beresp.http.Set-Cookie;
}
#
# don't cache response to posted requests or those with basic auth
if ( req.request == "POST" || req.http.Authorization ) {
return (hit_for_pass);
}
#
# only cache status ok
if ( beresp.status != 200 ) {
return (hit_for_pass);
}
#
# don't cache search results
if( req.url ~ "\?s=" ){
return (hit_for_pass);
}
#
# else ok to cache the response
set beresp.ttl = 24h;
return (deliver);
}
#
sub vcl_deliver {
# add debugging headers, so we can see what's cached
if (obj.hits &gt; 0) {
set resp.http.X-Cache = "HIT";
}
else {
set resp.http.X-Cache = "MISS";
}
# remove some headers added by varnish
unset resp.http.Via;
unset resp.http.X-Varnish;
}
#
sub vcl_hash {
hash_data( req.url );
# altering hash so subdomains are ignored.
# don't do this if you actually run different sites on different subdomains
if ( req.http.host ) {
hash_data( regsub( req.http.host, "^([^\.]+\.)+([a-z]+)$", "\1\2" ) );
} else {
hash_data( server.ip );
}
# ensure separate cache for mobile clients (WPTouch workaround)
if( req.http.User-Agent ~ "(iPod|iPhone|incognito|webmate|dream|CUPCAKE|WebOS|blackberry9\d\d\d)" ){
hash_data("touch");
}
return (hash);
}</pre>
<p>The post <a href="https://chrisgilligan.com/consulting/varnish-vcl-and-config-for-wordpress-with-w3-total-cache/">Varnish VCL and Config for WordPress with W3 Total Cache</a> appeared first on <a href="https://chrisgilligan.com">Chris Gilligan » new media</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://chrisgilligan.com/consulting/varnish-vcl-and-config-for-wordpress-with-w3-total-cache/feed/</wfw:commentRss>
			<slash:comments>25</slash:comments>
		
		
			</item>
		<item>
		<title>WordPress with W3 Total Cache on Nginx with APC (Virtualmin)</title>
		<link>https://chrisgilligan.com/wordpress/wordpress-with-w3-total-cache-on-nginx-with-apc-virtualmin/</link>
					<comments>https://chrisgilligan.com/wordpress/wordpress-with-w3-total-cache-on-nginx-with-apc-virtualmin/#comments</comments>
		
		<dc:creator><![CDATA[Chris Gilligan]]></dc:creator>
		<pubDate>Mon, 12 Mar 2012 15:25:34 +0000</pubDate>
				<category><![CDATA[Web Server Performance Tuning]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[virtualmin]]></category>
		<category><![CDATA[w3 total cache]]></category>
		<category><![CDATA[w3tc]]></category>
		<guid isPermaLink="false">https://chrisgilligan.com/?p=672</guid>

					<description><![CDATA[<p>Virtualmin now includes support for Nginx web server. I deploy many WordPress sites with W3 Total Cache and APC Alternative PHP Cache, so I was very interested to see how Nginx performance compares to Apache for WordPress, and whether APC and W3TC would play nice with Nginx. I prefer to install WordPress in public_html/wordpress for [&#8230;]</p>
<p>The post <a href="https://chrisgilligan.com/wordpress/wordpress-with-w3-total-cache-on-nginx-with-apc-virtualmin/">WordPress with W3 Total Cache on Nginx with APC (Virtualmin)</a> appeared first on <a href="https://chrisgilligan.com">Chris Gilligan » new media</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p style="float: right; margin: 0 0 10px 15px; width:240px; height: auto;">
		<img src="https://d2lehxir4n36oh.cloudfront.net/wp-content/uploads/2012/03/virtualmin-nginx-wordpress-permalinks-apc.png?x25141" width="240" style="max-width: 100%; height: auto;" />
		</p><p><strong><a href="https://d2lehxir4n36oh.cloudfront.net/wp-content/uploads/2012/03/virtualmin-nginx-wordpress-permalinks-apc.png?x25141"><img decoding="async" class="alignright size-medium wp-image-673" title="virtualmin-nginx-wordpress-permalinks-apc" alt="" src="https://d2lehxir4n36oh.cloudfront.net/wp-content/uploads/2012/03/virtualmin-nginx-wordpress-permalinks-apc-300x187.png?x25141" width="300" height="187" srcset="https://d2lehxir4n36oh.cloudfront.net/wp-content/uploads/2012/03/virtualmin-nginx-wordpress-permalinks-apc-300x187.png?x25141 300w, https://d2lehxir4n36oh.cloudfront.net/wp-content/uploads/2012/03/virtualmin-nginx-wordpress-permalinks-apc-1024x638.png?x25141 1024w, https://d2lehxir4n36oh.cloudfront.net/wp-content/uploads/2012/03/virtualmin-nginx-wordpress-permalinks-apc.png?x25141 1202w" sizes="(max-width: 300px) 100vw, 300px" /></a>Virtualmin now includes <a title="Virtualmin Nginx" href="http://www.virtualmin.com/documentation/web/nginx">support for Nginx web server</a>.</strong> I deploy many WordPress sites with W3 Total Cache and APC Alternative PHP Cache, so I was very interested to see how Nginx performance compares to Apache for WordPress, and whether APC and W3TC would play nice with Nginx.</p>
<p>I prefer to install WordPress in public_html/wordpress for ease of development, compatibility with other scripts, etc. Accordingly, the suggested configuration is for WordPress installed in a subfolder. This info also assumes you have successfully installed APC Cache on your server, and set up a <em>clean</em> install of Virtualmin with Nginx as the Alternative Web Server. Switching from Apache to Nginx later is difficult, as is transferring apache virtual server backups. Best to start fresh and build from scratch.</p>
<h3>Testing the Virtualmin Nginx Modules</h3>
<p>Virtualmin does not support Nginx and Apache together, and there is no easy migration from Apache to Nginx, so it is suggested to begin with a fresh install of Virtualmin with no existing accounts.</p>
<p>If you would like to experiment with Nginx, and you already have a Virtualmin Pro license, you are permitted to set up Virtualmin on a second server for testing and migration. I run the extra Virtualmin Pro system on a VPS that I use for backups, slave DNS, and testing.</p>
<p>The Nginx modules are <a title="Virtualmin Nginx on GPL?" href="http://www.virtualmin.com/node/20602">also available for the free Virtualmin GPL version</a>. To install the modules, go to Virtualmin Package Updates (wbm-virtualmin-nginx and wbm-virtualmin-nginx-ssl).</p>
<h3>WordPress Plugins for this Setup</h3>
<ul>
<li><a title="Wordpress opcode cache, page cache, caching, database cache, browser cache" href="http://wordpress.org/extend/plugins/w3-total-cache/">W3 Total Cache</a> &#8212; adds opcode cache, minification, browser cache and page cache capabilities to WordPress&#8230; and it works with Nginx. Works best with Alternative PHP Cache to provide opcode and database cache. Setting APC for all caches works easiest with Nginx&#8230; setting to file caching introduces URL rewrite errors&#8230; See <a title="W3 Total Cache Settings" href="#w3tc-settings">W3TC Settings</a> information below for instructions on how to implement File caching.</li>
<li><a title="Wordpress Nginx Plugin" href="http://wordpress.org/extend/plugins/nginx-compatibility/">nginx Compatibility</a> &#8212; makes WordPress more compatible with Nginx, allows use of permalinks without /index.php/</li>
</ul>
<h3>Configuring Nginx for WordPress pretty URL Permalinks</h3>
<p>The nginx Compatibility plugin has support for pretty URLs, but you must configure Nginx to use them. You should add or edit the following URL path locations to nginx.conf for your virtual domain&#8230; either by direct edit, or via URL Path Locations in Virtualmin &gt; Services &gt; Configure Nginx Website (<em><a title="Virtualmin Nginx WordPress URL Path Locations" href="https://d2lehxir4n36oh.cloudfront.net/wp-content/uploads/2012/03/virtualmin-nginx-wordpress-permalinks-apc.png?x25141">see attached image&#8230;</a></em>). This config is for WP installed in /public_html/wordpress, so you will need to omit or change /wordpress if WP is installed in a different directory.</p>
<pre class="lang:default decode:true" title="nginx conf for wordpress">location ^~ /files/ {
rewrite /files/(.+) /wordpress/wp-includes/ms-files.php?file=$1 last;
}
location @wordpress {
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_NAME /index.php;
}
location ~ \.php$ {
try_files $uri @wordpress;
fastcgi_index index.php;
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ^~ /blogs.dir/ {
internal;
root /home/username/public_html/wordpress/wp-content;
}</pre>
<h3>Adding APC Support for a Virtual Domain</h3>
<p>Because Virtualmin&#8217;s implementation of Nginx uses php-fastcgi, each virtual domain will load its own php.ini file, so you can add the APC directives to that file (/home/domainname/etc/php5/php.ini)</p>
<p>Add the following to php.ini (adjust to your requirements)</p>
<pre class="lang:default decode:true" title="php.ini section for WordPress with W3 Total Cache">[APC]
extension = apc.so
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 12M
apc.optimization = 0
apc.num_files_hint = 256
apc.user_entries_hint = 1024
apc.ttl = 0
apc.user_ttl = 0
apc.gc_ttl = 600
apc.cache_by_default = 0
apc.filters = "-/home/username/public_html/scripts-not-to-cache/.*,-/home/username/public_html/apc/.*"
apc.slam_defense = 0
apc.use_request_time = 1
apc.mmap_file_mask = /tmp/apc.XXXXXX
apc.file_update_protection = 2
apc.enable_cli = 0
apc.max_file_size = 2M
apc.stat = 1
apc.write_lock = 1
apc.report_autofilter = 0
apc.include_once_override = 0
apc.rfc1867 = 0
apc.rfc1867_prefix = "upload_"
apc.rfc1867_name = "APC_UPLOAD_PROGRESS"
apc.rfc1867_freq = 0
apc.localcache = 1
apc.localcache.size = 256
apc.coredump_unmap = 0
apc.stat_ctime = 0</pre>
<h3>Reloading PHP-fastcgi processes after changes to php.ini</h3>
<p>You will need to reload the php-fastcgi processes if you change php.ini. Luckily, Virtualmin creates service scripts for each virtual domain, which you can use to reload PHP.</p>
<p>The service scripts are located in /etc/rc.d/init.d.<br />
<code>php-fcgi-domain1-com<br />
php-fcgi-domain2-com</code><br />
Script allows stop, start, restart<br />
e.g.<br />
<code>service php-fcgi-domain2-com restart</code></p>
<p><em><strong>The service may also be restarted via Webmin &gt; Services &gt; Bootup and Shutdown</strong></em></p>
<h3>Memory Considerations</h3>
<p>PHP FCGId will launch the number of sub-processes you specify in Virtualmin &gt; Server Configuration &gt; Website Options, so beware of the memory overhead if you specify a large number, because each will consume the amount of memory specified in  apc.shm_size. You may need to experiment with this value, depending on your server&#8217;s memory and potential traffic.</p>
<p>Virtualmin explains: &#8220;When PHP scripts for this domain as run via FCGId, the number of PHP processes set in this field will be kept running at all times to serve requests. You can increase this from the default of 4 to improve PHP script latency, or decrease it to reduce memory use. Setting it to None will cause PHP processes to be launched only as needed on demand, and to be cleaned up after some period of inactivity.&#8221;</p>
<p>Nginx support on Virtualmin is working well, and it is reported that the lead developer, Jamie Cameron, is working on a php-fpm implementation, which should increase performance and lessen memory requirements. Let&#8217;s hope this rumor is true!</p>
<h3><a title="W3 Total Cache Settings" name="w3tc-settings"></a>W3 Total Cache Settings</h3>
<p>Provided you use the nginx.conf settings described above, using APC cache for all W3TC categories of cache/minify/etc. will work with no additional changes to the conf file. However, if you wish to choose Disk cache for page and/or minify cache, URL rewriting will not work properly on Virtualmin. You must include the location {&#8230;} directives in the nginx.conf created in your public_html root by W3TC, and add them after the location {&#8230;} directives described above.</p>
<p>You can do this either by copying the directives and pasting into /etc/nginx/nginx.conf, or (better) by using an include statement:</p>
<pre class="lang:python decode:true">[...]
location ^~ /blogs.dir/ {
internal;
root /home/username/public_html/wordpress/wp-content;
}
include /home/username/public_html/nginx.conf;
[...]</pre>
<p><em><strong>However, remember you will need to restart NginX web server after making changes to the W3TC configuration, because these will over-write the local nginx.conf file.</strong></em></p>
<h3>Conclusion</h3>
<p>Sorry, no benchmarks. See my <a title="Wordpress on Nginx with APC cache (Virtualmin)" href="http://nginx.chrisgilligan.com/" target="_blank">example/test site here</a>.</p>
<p>Nginx support on Virtualmin is working well, though I don&#8217;t see much improvement over Apache in terms of initial index page load, or time to first byte on the WordPress test site I created.  Cached and subsequent pages load very quickly, so it looks like there is an overall improvement. All WordPress functions seem to work well: comments, image uploads, etc. are no problem. I am interested to see if there is improvement with other scripts, especially phpbb3.</p>
<p>The post <a href="https://chrisgilligan.com/wordpress/wordpress-with-w3-total-cache-on-nginx-with-apc-virtualmin/">WordPress with W3 Total Cache on Nginx with APC (Virtualmin)</a> appeared first on <a href="https://chrisgilligan.com">Chris Gilligan » new media</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://chrisgilligan.com/wordpress/wordpress-with-w3-total-cache-on-nginx-with-apc-virtualmin/feed/</wfw:commentRss>
			<slash:comments>20</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Page Caching using Disk: Enhanced 
Content Delivery Network via Amazon Web Services: CloudFront: d2lehxir4n36oh.cloudfront.net
Lazy Loading (feed)

Served from: chrisgilligan.com @ 2026-08-25 16:46:31 by W3 Total Cache
-->