• Resolved webmaestro

    (@webmaestro)


    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 [email protected]
      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>
Viewing 4 replies - 16 through 19 (of 19 total)
  • Thread Starter webmaestro

    (@webmaestro)

    This has been resolved. I now have WP Super Cache running in WordPressMU via the vhost file (Apache server configuration instead of .htaccess files). The problem was related to missplaced WP Super Cache directives and obsolete Apache Directives.

    Thank you for your help!

    Burbridge

    (@cinemaminima)

    I run plain-vanilla WordPress 2.6x and it does not use fancy URIs, so it doesn’t use .htaccess files.

    In that case — where there are no rewrite rules anyway — what would be a way to install SuperCache without using .htaccess (don’t want to make Apache work on those unless absolutely necessary) ?

    Thanks for any comment or help regarding this!

    You can possibly use it in half-on mode, but you won’t get the static caching capabilities.

    Thread Starter webmaestro

    (@webmaestro)

    You could also do what I’ve done (of course you should use WordPress-specific configuration instead of the WordPressMU stuff I have), and configure WP Super Cache using the virtual CONF files (the initial purpose of this thread…).

    Following is the end result of my Virtual/vhost httpd CONF file. I’d be grateful for additional tips on improving my httpd CONF file… Here’s my permalink: /%year%/%monthnum%/%day%/%postname%/%post_id%/

    <VirtualHost *>
      ServerName www.mydomain.com
      ServerAlias mydomain.com
      ServerAdmin [email protected]
      DocumentRoot /path/to/wordpress-mu-X.Y.Z/
    
      LogLevel warn
      #OLD SCHOOL: Simple Logging
      #ErrorLog /path/to/apache/logs/my_error_log
      #CustomLog /path/to/apache/logs/my_access_log combined
    
      #NEW HOTNESS: Rotate Logs
      ErrorLog "|/path/to/apache/bin/rotatelogs /path/to/apache/logs/my_error_log.%Y%m%d 86400"
      CustomLog "|/path/to/apache/bin/rotatelogs /path/to/apache/logs/my_access_log.%Y%m%d 86400" combined
    
      #RewriteLog /path/to/apache/logs/my_rewrite.log
      #RewriteLogLevel 0
    
      <Directory "/path/to/wordpress-mu-X.Y.Z">
        #DISALLOW/IGNORE .htaccess files
        AllowOverride None
    
        Order Deny,Allow
        Allow from all
    
        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>  
    
        RewriteEngine On
        RewriteBase /
    
        # 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]
        # END WPSuperCache
    
        #uploaded files
        RewriteRule ^(.*/)?files/$ index.php [L]
        RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
        RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
    
        # add a trailing slash to /wp-admin
        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]
    
        #RewriteCond %{REQUEST_FILENAME} !-f
        #RewriteCond %{REQUEST_FILENAME} !-d
        #RewriteRule . /index.php [L]
    
        #<IfModule mod_security.c>
        #       <Files async-upload.php>
        #         SecFilterEngine Off
        #         SecFilterScanPOST Off
        #       </Files>
        #</IfModule>
      </Directory>
    
      # BEGIN supercache
      <Directory "/path/to/wordpress-mu-X.Y.Z/wp-content/cache">
        <IfModule mod_mime.c>
          AddEncoding 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>

    IMPORTANT:
    If you’re using WordPressMU, you’ll want to compare your CONF entries with the trunk/htaccess.dist file for each release.

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘[Plugin: WP Super Cache] httpd.conf or .htaccess for Apache Directives?’ is closed to new replies.