Return-Path: X-Original-To: apmail-httpd-users-archive@www.apache.org Delivered-To: apmail-httpd-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 67FE210900 for ; Fri, 20 Sep 2013 14:04:49 +0000 (UTC) Received: (qmail 53709 invoked by uid 500); 20 Sep 2013 14:04:46 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 53670 invoked by uid 500); 20 Sep 2013 14:04:45 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 53578 invoked by uid 99); 20 Sep 2013 14:04:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Sep 2013 14:04:40 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of covener@gmail.com designates 209.85.128.181 as permitted sender) Received: from [209.85.128.181] (HELO mail-ve0-f181.google.com) (209.85.128.181) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Sep 2013 14:04:34 +0000 Received: by mail-ve0-f181.google.com with SMTP id oy12so328552veb.26 for ; Fri, 20 Sep 2013 07:04:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=doQIkz9sE0pF5dqBNysI9L6Ir4E2A6KYLjfKYVT3z4k=; b=EvMCol5bVUzFSnvNvLHiYYnAnYkac6rVf+hO9IjuXIVIvXX7YI1csBTgotVk5SWRcq OWkcsV6kW3RCIje0dylhwqL+e3RhNGmBgg0eoynANZR+IGQSwdlP3ULx1NLd6wiqdANe x5pUQciODl4XaQzgmqiekoXcnS+8jwzTzv1QiigAIBsoA7EFqWk/o2Jd2Lra/y97Bzj4 Y+LB+yAe+Ht9YHJJn2u0MxzpRpX4Vc5z/CW039kfTIYKZvCOBXT9M0jlnSbLIQqfdXV5 peGav4Fhp+7h2lgXyrxHZxgJuiFhctMCRcyNQqdRcEoZz3E4I/uqdQHdVvhhh7DWlnYB uZFQ== MIME-Version: 1.0 X-Received: by 10.58.136.4 with SMTP id pw4mr6690470veb.10.1379685853868; Fri, 20 Sep 2013 07:04:13 -0700 (PDT) Received: by 10.58.68.131 with HTTP; Fri, 20 Sep 2013 07:04:13 -0700 (PDT) In-Reply-To: References: Date: Fri, 20 Sep 2013 10:04:13 -0400 Message-ID: From: Eric Covener To: users@httpd.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Subject: Re: [users@httpd] Relative efficiency of replacing rewrite rules with rewriteMaps On Fri, Sep 20, 2013 at 9:11 AM, Paul Beckett wrote: > I would like to try and reduce the number of rewrite rules I have (from > 5000) to a much smaller number of rewrite maps. My main goals in doing this > are to improve site performance, and make configuration more manageable. > I need to be able to handle the following cases: > /dir1/link1 -> /dir1/other1 > /dir1/link2 -> /dir1/random2 > /dir1/link3 -> /dir1/link3 [no change, and I don't know all the > possible URL's] > /dir2/link4 -> /dir3/link5 > > The best I've been able to come up with in the Apache config is: > > RewriteMap map-urla txt:/path/to/map-urla > RewriteCond ${map-urla:$1} >"" [NC] If you used a regex in the 2nd parm, you could capture the map lookup here and not run it again for substitution. Probably faster then the cached lookup from the map. > RewriteRule ^/dir1/map-urla(.*)$ /dir1/${map-urla:$1} [R] > > This works in terms of getting URL's to the write place, but before I expend > a colossal amount of effort rewriting over 5000 lines of config, I'm hoping > to clarify that this will actually provide a performance benefit. > In particular, will it only evaluate the /dir1/ path once, and skip over > this for other urls (eg. /dir2/) or will the rewriteCond be evaluated first > going through every line in the rewritemap prior to evaluating the /dir1? Rewriterule evaluated, but not substituted, first. That is where you want to discriminate the most, not in the conditions, even though it's tempting to do that. You'll probably have to simulate it before really porting the 5000 rules to get a feel if it's only academically better/worse. But at 5000 rules, if 'L' is not used and carefully ordered it should help. -- Eric Covener covener@gmail.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org