mod_rewrite to speed up twiki

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

I have been following Christian Folini's "Rock your Wiki!" article in
the April issue of Sysadmin magazine.  I have implemented his rules and
script to generate a cached page but things do not seem to be working.
I have reviewed the logs and it seems like the rules below work.

I was concerned about the setting of the variables but according to the
log it works.  However, it seems that the generator does not return the
correct cache file name when run via mod_rewrite.  

### Rules begin

RewriteEngine   On
RewriteLogLevel 9

RewriteLog      /var/log/httpd/rewrite.log
RewriteLock     /var/log/httpd/rewrite.lock

RewriteMap      generator
prg:/home/httpd/twiki/bin/content-cache-generator.pl
RewriteMap      remover
prg:/home/httpd/twiki/bin/content-cache-remover.pl

RewriteRule !/twiki/bin/(view|save)/ - [last]

RewriteRule /twiki/bin/(view|save)/(.*)/(.*)$ -
[ENV=TWIKIWEB:$2,ENV=TWIKIPAGE:$3]

RewriteCond
/home/httpd/twiki/cache/%{ENV:TWIKIWEB}.%{ENV:TWIKIPAGE}.html -s
RewriteRule /twiki/bin/view/
/twiki/cache/%{ENV:TWIKIWEB}.%{ENV:TWIKIPAGE}.html [last]

RewriteRule /twiki/bin/view/
${generator:%{ENV:TWIKIWEB}/%{ENV:TWIKIPAGE}} [last]

RewriteRule /twiki/bin/save/
/twiki/bin/save/${remover:%{ENV:TWIKIWEB}/%{ENV:TWIKIPAGE}} [last]

DocumentRoot /home/httpd/

### Rules end

The content-cache-generator.pl script seems to work at the command line.
I enter IT/WebHome and it returns /twiki/cache/IT.WebHome.html and the
file does exist.

### content-cache-generator.pl generator script begins

#!/usr/bin/perl -w
use strict;
use LWP;

$| = 1; # turn off buffering

my ($str, $res) = "";
my $ua = LWP::UserAgent->new(timeout => 10);

$ua->no_proxy('servername');
while ( <STDIN> ) {
        chomp($_);
        $str = $_;
        $res =
$ua->get("http://servername/twiki/bin/view/$str\?x-ignore";);
        if ($res->is_success && $res->status_line eq "200 OK") {
                s/\//./;
                if (open(FILE, ">/home/httpd/twiki/cache/$_.html")) {
                        print FILE $res->content;
                        close(FILE);
                        print "/twiki/cache/$_.html\n";
                }
                else {
                        print "/twiki/bin/view/$str\n";
                }
        }
        else {
                print "/twiki/bin/view/$str\n";
        }
}

### content-cache-generator.pl generator script begins

I have included the rewrite logs for the one request for IT/WebHome.  It
seems to me that there is too much in the file for the one request.  I
expect to see two requests (one from my pc to apache and the other from
the apache server during the mod_rewrite call to the generator script)

Sorry for the length of the email but I have been try to figure this out
for days...

### Begin log file 

Log file attached...

Thanks in advance

Tim

**********************************************************************
This E-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary, confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this E-mail message immediately. 

Le present message electronique (y compris les pieces qui y sont annexees, le cas echeant) s'addresse au destinataire indique et peut contenir des renseignements de caractere prive ou confidentiel. Si vous n'etes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire. Si ce message vous a ete transmis par erreur, veuillez en informer l'expediteur et le  supprimer immediatement.

Attachment: rewrite.log.tar.gz
Description: rewrite.log.tar.gz

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux