I have patched the D5 module for use with D6, it works well but only caches the index page and its alias. I end up with index.html and a symlink to index.html called home.html in the cache directory. No other pages will cache automatically, the only way I can get the cache file to be created is to request pages without using clean url. eg. http://www.example.com/index.php?q=node/15
Then I get the cache/node/15.html and the symlink to the clean url alias html file in the cache directory. I can then browse to the clean url address and will be served the cached page, suggesting that the rewrite rules are working fine.
I have added some watchdog entries in the boost.module and boost.api.inc files, the results show me that the the module is fine, that all the functions required to generate the cache files are visited, however the following line I added in the boost_init function;
watchdog('boost', '$_GET[q]: ' . $_GET['q'], array(), WATCHDOG_NOTICE);
No matter which page I request the entry in the log shows '$_GET['q']: node/3' which is the home page. This makes the $path and $alias wrong all the way through the process. The only time I get the correct info for the page requested is if I do as I said above by requesting the non clean url, when I do that I get the right node request in the log, but immediatedly followed again by the node/3.
I am new to drupal and don't really understands the precedence of the module files etc but I am lead to think that this problem is down to something outside of the boost module, although I have no idea how to go about debugging further.
Help!

Comments

wobbler’s picture

Status: Active » Fixed

Ok, after nearly smashing my computer up in frustration I have got to the bottom of the problem, and it was obvious really. This has been one of those problems that has taught me a whole load about drupal and Apache, so it was worth it really.
The problem was not with the Boost code at all. In fact with the amount of testing I have done in the last few days, I am pretty happy that the patch works well. I even ended up creating a 5.7 instance of drupal and back porting my site to it to find out that the the problem was with my mod_rewrite setup.
I am using server config files rather than htaccess files to benefit from the increased performance. I didn't have the RewriteBase directive in the config, the D6 patch htaccess/boosted.txt doesn't mention that it is a requirement, and when I put it in Apache gave an error stating that it was only used in per directory configuration files (htaccess).
In reality it is required, but the RewriteBase directive needs to be in a <Directory> ... </Directory> block. I have enclosed the relevant section from my vhost config file.
NB. I have altered the Rewrite rules a bit, as during my debugging of the issues I discovered that the standard rules cause 4 unneccessary file and 2 directory accesses for each and every css, image, js, swf etc file in each page. This potentially serious performance hit would not be picked up by an Apache Bench (ab) test.

    DocumentRoot "/usr/share/drupal-6.2"

    CustomLog logs/access_log combined
    ErrorLog logs/error_log

    LogLevel Error

    ErrorDocument 404 /index.php

    DirectoryIndex index.php

    <IfModule mod_php5.c>
        php_value magic_quotes_gpc                0
        php_value register_globals                0
        php_value session.auto_start              0
        php_value mbstring.http_input             pass
        php_value mbstring.http_output            pass
        php_value mbstring.encoding_translation   0
    </IfModule>

    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault A1209600
        ExpiresByType text/html A1
    </IfModule>

    <Location /cache/>
      <IfModule mod_headers.c>
         Header add Expires "Sun, 19 Nov 1978 05:00:00 GMT"
         Header add Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
      </IfModule>
    </Location>

    <Directory "/usr/share/drupal-6.2">
      Options None
      Options +FollowSymLinks
      AllowOverride None
      <FilesMatch "\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
        Order allow,deny
      </FilesMatch>
      Allow from all

      <IfModule mod_rewrite.c>
        RewriteEngine on

        RewriteBase /

    #BOOST START

        RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
        RewriteCond %{REQUEST_FILENAME} !\.(ico|png|jpg|mov|gif|css|js|swf|html\?)(\W.*)?
        RewriteCond %{REQUEST_METHOD} ^GET$
        RewriteCond %{REQUEST_URI} !^/(cache|user|admin)
        RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}.html -f
        RewriteRule ^(.+) cache/%{SERVER_NAME}/0/$1.html [L]

        RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
        RewriteCond %{REQUEST_FILENAME} !\.(ico|png|jpg|mov|gif|css|js|swf|html\?)(\W.*)?
        RewriteCond %{REQUEST_METHOD} ^GET$
        RewriteCond %{REQUEST_URI} ^/$
        RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/index.html -f
        RewriteRule ^.+ cache/%{SERVER_NAME}/0/index.html [L]

        RewriteCond %{HTTP_COOKIE} !DRUPAL_UID
        RewriteCond %{REQUEST_FILENAME} !\.(ico|png|jpg|mov|gif|css|js|swf|html\?)(\W.*)?
        RewriteCond %{REQUEST_METHOD} ^GET$
        RewriteCond %{REQUEST_URI} !^/(cache|user|admin)
        RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI} -d
        RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}/index.html -f
        RewriteRule ^(.+) cache/%{SERVER_NAME}/0/$1/index.html [L]

    # BOOST END

        RewriteCond %{REQUEST_FILENAME} !^/$
        RewriteCond %{REQUEST_FILENAME} !\.(php|ico|png|jpg|mov|gif|css|js|swf|html\?)(\W.*)?
        RewriteCond %{REQUEST_FILENAME} !^/(files|misc|uploads)(/.*)?
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.+) index.php?q=$1 [L,QSA]

      </IfModule>

    </Directory>
alanburke’s picture

NB. I have altered the Rewrite rules a bit, as during my debugging of the issues I discovered that the standard rules cause 4 unneccessary file and 2 directory accesses for each and every css, image, js, swf etc file in each page. This potentially serious performance hit would not be picked up by an Apache Bench (ab) test.

Unrelated to this issue, but could you elaborate on this point?
Perhaps open an issue for core if it is relevant.

Regards
Alan

wobbler’s picture

Hi alan, I raised a bug report (http://drupal.org/node/276495), it isn't really reporting a bug, maybe I should have done a support request, posting this sort of thing is new to me. The changes I show above aren't so good, I think the big regexs are a killer. The bug report has some much better rewrite rules.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.