Forum Moderators: phranque

Message Too Old, No Replies

directory method versus xbithack

performance questions

         

D_Blackwell

4:02 am on Jun 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to add SSI to handle a graphic logo and a couple of <div>s in the header. The site is all .html and this will affect abourt 200 pages. .shtml doesn't seem to be an option. I am planning to add
AddType text/html .html
AddHandler server-parsed .html
to the .htaccess to handle everything.

I've read about a price against performance, but haven't been able to learn anything firm about that. What are my options?

keyplyr

7:01 am on Jun 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I went that route and noticed a slowdown, although not huge. I opted for PHP includes instead, which AFAIK causes no noticeable slowdown.

As it pertains to this scenario, the differecnce is:

SSI - the server parses each page in your domain looking for the SSI, even if there is none.
PHP - the server responds to the PHP include tag, if/when they occure.

D_Blackwell

2:17 am on Jun 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there any way to use PHP includes without the .php extension? The idea sounded good and I jumped right on it. Implementing it was an "uh oh" moment. I'm pretty well locked into .html files. Nearly every page on the site ranks #1 or Page #1 for its niche. I can't just change the files. It's the same issue that holds me from switching to .shtml

Do I have any options beside the Handler in the .htaccess? If not, what is the likely downside on performance? The site is necessarily image heavy, so I hate to give up more in this area. But I have to add includes ASAP. This site was never supposed to do so well.

Should I go to .shtml or .php for future pages? The site is steadily expanding.

jdMorgan

4:14 am on Jun 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The server has to parse files if you use either SSI or PHP, so that's a wash. Image files won't need to be parsed for SSI or PHP includes, so in this case it may be 'good' that you have an image-heavy site; Any decrease in performance due to includes will be swamped by all those image loads.

Your URLs need not have any relationship to the names of their content files, as long as you have the correct handlers and MIME-types configured. You can use mod_rewrite to map .html URLs to .php or .shtml files any way you like.

XBitHack allows you to control SSI parsing and provide Last-Modified headers with finer control than AddHandler. The downside is that XBitHack is controlled by the files' execution permission bits, and so you must be careful to set those bits on all new files uploaded to your server. If these bits get reset, the pages won't be parsed for SSI and won't return correct Last-Modified headers. Using AddHandler, the files will always be parsed for SSI, but you'd still need to use XBitHack to control the Last-Modified headers. At least it's truthfully labeled "XBitHack.

Jim

keyplyr

5:30 pm on Jun 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is there any way to use PHP includes without the .php extension?

In .htaccess:

AddHandler application/x-httpd-php .php .html

In mark-up:

<?php include("directory/file_name.html");?>

The server has to parse files if you use either SSI or PHP, so that's a wash.

Yes Jim, but instead of parsing every HTML document for SSI before it is given to the browser which does slow things a little, I've found using PHP includes is much faster because only pages are parsed if they contain the PHP include. Of course, I may be wrong on this ;)

jdMorgan

6:41 pm on Jun 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> pages are parsed if they contain the PHP include

Pages must be parsed in order to determine that they contain PHP code, just as with cgi-type SSI.
If SSI is not configured on a server, pages are simply transmitted to the client; the server has no need to "read through" them to look for "<?php" or "<!--#", indicating a php or cgi include, respectively. If you enable server parsing, then the server must scan through the entire contents of each page looking for those strings and inserting the appropriate content or executing the appropriate handler to "construct" the page before it can be sent to the client.

So, the only fundamental difference in this regard between cgi and php includes is the handler that gets called when the server detects an included sequence.

Jim

D_Blackwell

4:28 am on Jun 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your URLs need not have any relationship to the names of their content files, as long as you have the correct handlers and MIME-types configured. You can use mod_rewrite to map .html URLs to .php or .shtml files any way you like.

Would you expand on this, and where I might go tolearn enough more to focus my next questions?