You are here: Re: Cached include? « All PHP « IT news, forums, messages
Re: Cached include?

Posted by J.O. Aho on 09/27/49 11:39

mark wrote:
> "d" <d@example.com> wrote in message
> news:0t2Hf.18086$wl.6727@text.news.blueyonder.co.uk...
>> "mark" <mark@localhost.net> wrote in message
>> news:43eca863$0$82675$ed2619ec@ptn-nntp-reader03.plus.net...
>>> I have one very large include, which is an array. It's included when
>>> index.php is loaded. However, I now need to use the same include on
>>> page2.php, and page3.php and page4.php. Is there a smart way to do this
>>> and mimize load times on each sudsequent page?
>> Just put it in an include, and include it on all those pages :)
>
> yea, but doesn't that result in a large download time for end user? if the
> original include is 100KB, that means index.php is 100KB+ already, if I
> include it on the other pages, they too will be that large?

The visitor won't download everything, they will only get the stuff that is
processed by PHP. Lets make a simple example, we ignore the size of HTTP
headers and such and just look at the actual PHP code size.

We have this simple scipt:
--- silly random value ---
<?PHP
for($i=0;$i<5;$i++) {
$q+=$i*rand();
}

echo "Q=$q\n";
?>
--- end of file ---

The file itself is 66 bytes long

The output from the PHP script when run is

--- start of output ---
Q=8510522081
--- end of output ---

This is 13 bytes (new line is one byte too).

So when the visitor requests a php page, they get the output (in this case 13
bytes), no matter if the script itself is 66 bytes large or if it's 8Mbytes large.

All code are processed at the server, this is why it's called server side
script. Code that is sent to a visitor and it's the visitors computer that
processes it, is called client side script and the most common such is javascript.


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация