We've implemented WP Super Cache 0.8.2 in our WordPressMU 2.6.1 install, and are having intermittent success seeing 'cached' pages (see [Plugin: WP Super Cache] Not all pages are returned cached).
NOTE: We haven't seen any caching for any posts.
Our issue is similar to another recent forum post
[Plugin: WP Super Cache] How do I know it's really caching?.
But this post isn't about those questions... ;-) This post hopes to answer the question, and perhaps outline the steps to implement WP Super Cache, and place all Apache Directives (RewriteCond, RewriteRule, etc.) in the Apache virtual conf file, instead of in the DOCROOT/.htaccess and DOCROOT/wp-content/cache/.htaccess files.
Our Network & System Ops folks encourage us to place RewriteRule and other Apache Directives in the httpd virtual .conf file(s) where possible. FWIW, AllowOverrides All is specified, but not currently in use.
I've attempted to enable WP Super Cache by creating the DOCROOT/.htaccess and DOCROOT/wp-content/cache/.htaccess files as WP Super Cache seems to expect (not placing the Directives in the httpd virtual conf file). The home page of each blog loaded, but I immediately received errors when accessing any POSTS.
I tried placing the contents of both DOCROOT/.htaccess and DOCROOT/wp-content/cache/.htaccess files into the httpd virtual conf file (see code below), and the pages loaded slowly, but I was unable to see the <!-- super cache --> lines (see this post).
I was most successful placing the DOCROOT/.htaccess content in the httpd virtual conf file but creating the DOCROOT/wp-content/cache/.htaccess file. The results were the same as above (see this post), but it felt snappier.
Any ideas?
<VirtualHost *>
ServerName www.domain.com
ServerAlias domain.com
ServerAdmin support@domain.com
DocumentRoot /path/to/wordpress-mu-X.Y.Z/
LogLevel warn
ErrorLog /var/apache/logs/wpmu_error_log
CustomLog /var/apache/logs/wpmu_access_log combined
RewriteLog "/var/log/apache/rewrite.log"
RewriteLogLevel 0
<Directory "/path/to/wordpress-mu-X.Y.Z">
AllowOverride All
Order Deny,Allow
Allow from all
RewriteEngine On
FileETag INode MTime Size
#ExpiresActive On
#ExpiresDefault "modification plus 30 minutes"
#<FilesMatch "\\.(html|htm|php|jpg|gif|txt)$">
#Header set Cache-Control "max-age=1h, only-if-cached"
#</FilesMatch>
RewriteBase /
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ /$1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
#RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# BEGIN WPSuperCache
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{QUERY_STRING} !.*attachment_id=.*
RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WPSuperCache
</Directory>
# BEGIN supercache
<Directory "/path/to/wordpress-mu-X.Y.Z/wp-content/cache">
<IfModule mod_mime.c>
AddEncoding x-gzip .gz
AddType text/html .gz
</IfModule>
<IfModule mod_deflate.c>
SetEnvIfNoCase Request_URI \.gz$ no-gzip
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control 'max-age=300, must-revalidate'
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html A300
</IfModule>
</Directory>
# END supercache
</VirtualHost>