Pothi,
Thanks for the reply. I took a look at the page cache and it uses _gzip so I thought I would implement that through nginx along with using the W3 method of using rewrite to serve out the .gzip version. The page_enhanced cache method is quite clever because it uses parameters that are available so that you can rewrite without even using php.
Here is the Nginx conf just in case someone finds it useful. For now Nginx is serving out page and minimize files and in gzip if the browser supports it.
server
{
server_name www.mydomain.com;
listen 8080;
root /your/root/htdocs;
charset utf-8;
# BEGIN W3TC Page Cache core
set $w3tc_rewrite 1;
if ($request_method = POST) {
set $w3tc_rewrite 0;
}
if ($query_string != "") {
set $w3tc_rewrite 0;
}
#if ($http_cookie ~* "comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_swit")
if ($http_cookie ~* "comment_author|wp\-postpass|wordpress_logged_in|wptouch_swit")
{
set $w3tc_rewrite 0;
}
set $w3tc_enc "";
if ($http_accept_encoding ~ gzip)
{
set $w3tc_enc _gzip;
}
set $w3tc_ext "";
if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.html$w3tc_enc" )
{
set $w3tc_ext .html;
}
if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.xml$w3tc_enc")
{
set $w3tc_ext .xml;
}
if ($w3tc_ext = "") {
set $w3tc_rewrite 0;
}
if ($w3tc_rewrite = 1)
{
rewrite .* "/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ext$w3tc_enc";
}
location ~ /wp-content/cache/page_enhanced.*html$ {
expires modified 86400s;
add_header X-Cached "W3TC";
add_header Vary "Accept-Encoding, Cookie";
add_header Pragma "public";
add_header Cache-Control "max-age=86400, public";
}
location ~ /wp-content/cache/page_enhanced.*gzip$ {
gzip off;
types {}
default_type text/html;
expires modified 86400s;
add_header X-Cached 'W3TC';
add_header Vary 'Accept-Encoding, Cookie';
add_header Pragma 'public';
add_header Cache-Control 'max-age=86400, public';
add_header Content-Encoding gzip;
}
# END W3TC Page Cache core
# START W3TC Minify
#rewrite ^/wp-content/cache/minify.*/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php
location ~*
^.+.(js|css)$
{
try_files $uri @apachesite;
}
set $w3tc_enc "";
if ($http_accept_encoding ~ gzip) {
set $w3tc_enc .gzip;
}
#try_files $uri @apachesite;
if (-f $request_filename$w3tc_enc) {
rewrite (.*) $1$w3tc_enc break;
}
#rewrite ^/wp-content/cache/minify/(.+\.(css|js))$ /wp-content/plugins/w3-total-cache/pub/minify.ph$
location ~ /wp-content/cache/minify.*\.js$ {
types {}
default_type application/x-javascript;
expires 1y;
add_header X-Cached 'W3TC';
add_header Vary "Accept-Encoding";
add_header Pragma "public";
#add_header Cache-Control "max-age=604800, public";
add_header Cache-Control "public";
}
location ~ /wp-content/cache/minify.*\.css$ {
types {}
default_type text/css;
expires 1y;
add_header X-Cached 'W3TC';
add_header Vary "Accept-Encoding";
add_header Pragma "public";
#add_header Cache-Control "max-age=604800, public";
add_header Cache-Control "public";
}
location ~ /wp-content/cache/minify.*js\.gzip$ {
gzip off;
types {}
default_type application/x-javascript;
expires 1y;
#expires modified 604800s;
add_header X-Cached 'W3TC';
add_header Vary "Accept-Encoding";
add_header Pragma "public";
#add_header Cache-Control "max-age=604800, public";
add_header Cache-Control "public";
add_header Content-Encoding gzip;
}
location ~ /wp-content/cache/minify.*css\.gzip$ {
gzip off;
types {}
default_type text/css;
expires 1y;
add_header X-Cached 'W3TC';
add_header Vary "Accept-Encoding";
add_header Pragma "public";
#add_header Cache-Control "max-age=604800, public";
add_header Cache-Control "public";
add_header Content-Encoding gzip;
}
location @apachesite{
access_log off;
add_header Server Apache/2;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxx.xxx.x.xx:80;
}
# END W3TC Minify
location ~*
^.+.(jpg|png|gif|pdf|flv|swf|ico|txt|cur|ico)$
{
try_files $uri @apachesite;
gzip on;
gzip_static on;
access_log off;
expires 1y;
}
location / {
access_log off;
add_header Server Apache/2;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxx.xxx.x.xx:80;
}
}
server {
server_name ywca-blog.smywca.org *.ywca-blog.smywca.org *.ywca-blog.smywca.com *.ywca-blog.thescollards.com;
listen 8080;
root /www/ywca/blog/htdocs;
location ~*
^.+.(jpg|png|gif|js|css|pdf|flv|swf|ico|txt|cur)$
{
gzip on;
gzip_static on;
access_log off;
expires 1y;
}
location / {
access_log off;
add_header Server Apache/2;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxx.xxx.x.xx:80;
}
}
Most likely in the future I will just let Apache serve out the page cached files so that I can track them in the Apache server logs.
Craig