Hi Frederick,
I believe the first Cache-Control is from the Page Cache (Cache home page, Cache requests only.., Don’t cache page.. , are checked).
If page cache expired (older than 3600 secs) then the header would be like this:
curl -I www.lifebit.me
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 27 Aug 2012 15:18:25 GMT
Content-Type: text/html
Content-Length: 71674
Last-Modified: Mon, 27 Aug 2012 13:31:34 GMT
Connection: keep-alive
Vary: Accept-Encoding
Expires: Mon, 27 Aug 2012 14:31:34 GMT
Cache-Control: no-cache
Vary: Accept-Encoding, Cookie
Pragma: public
Cache-Control: public, must-revalidate, proxy-revalidate
Accept-Ranges: bytes
If page cache is not expired yet, the http header would be like this:
curl -I www.lifebit.me
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 27 Aug 2012 15:22:37 GMT
Content-Type: text/html
Content-Length: 71762
Last-Modified: Mon, 27 Aug 2012 15:22:31 GMT
Connection: keep-alive
Vary: Accept-Encoding
Expires: Mon, 27 Aug 2012 16:22:31 GMT
Cache-Control: max-age=3594
Vary: Accept-Encoding, Cookie
Pragma: public
Cache-Control: public, must-revalidate, proxy-revalidate
Accept-Ranges: bytes
If there is no page cache:
curl -I www.lifebit.me
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 27 Aug 2012 15:29:43 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Pingback: https://www.lifebit.me/xmlrpc.php
Last-Modified: Mon, 27 Aug 2012 15:29:43 GMT
Vary: Cookie
Expires: Mon, 27 Aug 2012 16:29:43 GMT
Pragma: public
Cache-Control: public, must-revalidate, proxy-revalidate
If I disable Set cache control header:
curl -I www.lifebit.me
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 27 Aug 2012 15:25:53 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
X-Pingback: https://www.lifebit.me/xmlrpc.php
Last-Modified: Mon, 27 Aug 2012 15:25:53 GMT
Vary: Cookie
Expires: Mon, 27 Aug 2012 16:25:53 GMT
I’m using W3TC generated nginx.conf in my web root, and I don’t have any specific nginx conf to handle static files or html.
# BEGIN W3TC Page Cache cache
location ~ /wp-content/w3tc/pgcache.*html$ {
expires modified 3600s;
add_header Vary "Accept-Encoding, Cookie";
add_header Pragma "public";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~ /wp-content/w3tc/pgcache.*gzip$ {
gzip off;
types {}
default_type text/html;
expires modified 3600s;
add_header Vary "Accept-Encoding, Cookie";
add_header Pragma "public";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
add_header Content-Encoding gzip;
}
# END W3TC Page Cache cache
# BEGIN W3TC Browser Cache
gzip on;
gzip_types text/css application/x-javascript text/x-component text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
location ~ \.(css|js|htc)$ {
expires 31536000s;
add_header Pragma "public";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
expires 3600s;
add_header Pragma "public";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$ {
expires 31536000s;
add_header Pragma "public";
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
rewrite ^(.*\/)?w3tc_rewrite_test$ $1?w3tc_rewrite_test=1 last;
set $w3tc_rewrite 1;
if ($request_method = POST) {
set $w3tc_rewrite 0;
}
if ($query_string != "") {
set $w3tc_rewrite 0;
}
if ($http_host != "www.lifebit.me") {
set $w3tc_rewrite 0;
}
set $w3tc_rewrite2 1;
if ($request_uri !~ \/$) {
set $w3tc_rewrite2 0;
}
if ($request_uri ~* "(sitemap(_index)?\.xml(\.gz)?|[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?)") {
set $w3tc_rewrite2 1;
}
if ($w3tc_rewrite2 != 1) {
set $w3tc_rewrite 0;
}
set $w3tc_rewrite3 1;
if ($request_uri ~* "(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|\/feed\/|wp-.*\.php|index\.php)") {
set $w3tc_rewrite3 0;
}
if ($request_uri ~* "(wp\-comments\-popup\.php|wp\-links\-opml\.php|wp\-locations\.php)") {
set $w3tc_rewrite3 1;
}
if ($w3tc_rewrite3 != 1) {
set $w3tc_rewrite 0;
}
if ($http_cookie ~* "(comment_author|wp\-postpass|wordpress_\[a\-f0\-9\]\+|wordpress_logged_in)") {
set $w3tc_rewrite 0;
}
if ($http_user_agent ~* "(W3\ Total\ Cache/0\.9\.2\.4)") {
set $w3tc_rewrite 0;
}
set $w3tc_ua "";
set $w3tc_ref "";
set $w3tc_ssl "";
set $w3tc_enc "";
if ($http_accept_encoding ~ gzip) {
set $w3tc_enc _gzip;
}
set $w3tc_ext "";
if (-f "$document_root/wp-content/w3tc/pgcache/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl.html$w3tc_enc") {
set $w3tc_ext .html;
}
if ($w3tc_ext = "") {
set $w3tc_rewrite 0;
}
if ($w3tc_rewrite = 1) {
rewrite .* "/wp-content/w3tc/pgcache/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl$w3tc_ext$w3tc_enc" last;
}
# END W3TC Page Cache core
The nginx.conf above is my current active configuration, Page Cache (cache home page, cache request only.., don’t cache pages..), Browser Cache (set expires header, set cache control header, enable http gzip, cache control policy: cache with validation public, must-revalidate, proxy-revalidate).
Thanks for your reply Frederick, please let me know if you need any info from me.