homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum


 4:20 am on Mar 18, 2013 (gmt 0)

Oi! Forums! I capitalized that subject line for a reason!

Today's speculative question.

As a matter of routine, we tell people that
can be collapsed to
(jpe?g|png|gif) [NC]

But does this really save server time?
jpe?g [NC] = JPG, jpg, JPEG and jpeg, sure.

But it also =

:: pause here to whap self upside of head as I figure out there are 2^3 x 3 = 24 possibilities, not 2^3 x 2 = 16 ::


This is fine if your graphics software went haywire and you really do have all those permutations. But otherwise you have to check for at least two options at each step--and you already know that one of those options will never apply. If j then never P; if J then never p. Isn't it faster to say "Once you're got the first letter, each subsequent test only has one possible match"? Does it take more time for the server to read those 10-15 extra bytes and parse a few more pipes?



 12:17 pm on Mar 19, 2013 (gmt 0)

I've never tested it personally. And I would imagine even if I did the results may be different on different setups depending on the regex engine implemented at compile time. I, for one, would be interested to hear/see your results if you decide to undertake the task :P


 9:57 pm on Mar 19, 2013 (gmt 0)

depending on the regex engine implemented at compile time

Matter of fact that's the biggest variable I can think of. Not "regex engine" but "compile time". In a config file, Regular Expressions are parsed once, at startup, and then cached. In htaccess they are parsed all over again each time the server meets them. So you could have a setup where Task A takes more time than Task B -- but doing Task A once takes less time than doing Task B many times.

Does "look for 'P' or 'p'" take more time than "look for 'P'" alone? Once you get deep into the bowels of the computer, I doubt there's any inherent connection between P and p. The [NC] has triggered some previous function that tells it to match up 50 and 70. Or 80 and 112, as the case may be.

I don't think I could test it without leading to irate form letters from the host ;) Apparently they tell you when you are using excessive RAM and need to look into a VPS. And despite all the times I've managed to break a php include-- most recently yesterday-- or created a perpetual-motion error,* I've always done it without placing undue strain on server resources.

* <ot>
There exists at least one circumstance where
RewriteRule (.*) $1
does not lead to an infinite loop. This was an entertaining discovery; I've put it in the Trick Questions bin alongside "The light turned green so I had to wait longer".

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved