July 24th, 2000, 11:47 AM
-
I work with web sites that use Apache SSI (server side include) statements extensively to generate page headers and navigation. Sometimes the includes nest up to five pages deep. (They consist of mainly if statements and other includes).
I'm programming a new site from the ground up over the next week and I expect to be using PHP for database queries and dynamic pages in the future. So I'd like to use PHP from the ground up so I can plug in these features later.
My question is: If I use PHP statements to perform simple SSI tasks that I'm used to using, will the performance of my site
benefit or suffer? Should I stick to SSI and simply use PHP virtual() commands to include headers/footers?
Thanks in advance.
July 25th, 2000, 02:08 PM
-
I am sure that the PHP include() or require() method is much faster than the SSI, method, as well as being more flexible.
This will be especially true if you are using the Zend optimizer.
July 25th, 2000, 05:31 PM
-
A guy helped me out on another forum and sent me these benchmark results:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>
Apache includes a benchmarking utility (ab) that might be informative. I ran a test on my several-years-old K6-300 with 10,000 iterations of an HTTP fetch. The file included four references to a small text file. Here are the results:
virtual() 66.756 seconds
readfile() 57.146 seconds
ssi #include 44.377 seconds [/quote]
This was performed with PHP3. Can I expect better results with PHP4? I remeber reading benchmarks somwhere commenting that PHP4 with Zend renders dynamic pages almost as fast as Apache serves static HTML.
Any comments?
[This message has been edited by morden (edited July 25, 2000).]
July 26th, 2000, 12:49 PM
-
Well, yes, hehe...
1. The virtual() method is just a way for PHP to call the Apache SSI include function, so now you are parsing the request twice. Of course it will be slower.
2. readfile() lets PHP perform a 'console' type operation; reading a file and returning it to the standard output, which may be useful at times, but is certainly not the most efficient way to include content.
As I said, the PHP include() or require() functions are what you want to research.
http://www.php.net/manual/function.require.php
http://www.php.net/manual/function.include.php
For most of your needs, you would probably want require(), since it evaluates only once, whether it's placed multiple time on a page or not. It definitely beats SSI for speed and functionality (try to include a page from somewhere else on the web). In fact, I'm willing to bet that with require() and PHP4/Zend, on a large website you would actually see a speed INCREASE over serving completely static pages, since you reduce disk I/O.