Vector logo of the PHP programming language wi...

Today we lit a light reading for php cache the html. Here we talk about caching the output of our code and not as I have written to cash out to the skritpovete opcode level with eAccelerator. So stuff – Let us remind ourselves of the quick work of the php-it. Submit the request web server-He accepts us a parameters which we submit it then submits them to the php script he compiles and spit out results in html version. It's in a fairly general lines. What is our idea here over requests, over large blocks or not so big blocks like a direct draw straws once compiled output. The advantages are obvious – namalâna times, less load and consumption of resources. As a whole is not opening the hot water or something who knows how complicated. There are multiple classes for this purpose, such as PHP Pear Cache_Lite which has a great functionality but I think in the future to write mine with more streamlined structure and my requirements for write caching. Now we will take a look at aborigenskiâ option with Output Control Functions. So let's cash out something –

//start cache all output after that will be saved

ob_start();

//generate output

echo 'Some dynamic output';

echo 'Some other dynamic output ...';

//assign output into variable

$var=ob_get_contents();

//close cache output

ob_end_flush();

The above code is trivial but let me explain what happened. First we declare what part in the code starts caching. Then you generate a more standard way of exit code. Then the generated output joins variable that will be available later, whether in a file or during sessions, it's your decision. Finally, remove and disable caching. Quite a trivial operation if Let's say geenriraneto the cache goes through huge blocks of code so we can save a lot of CPU time as cash out for a while, or for a session. Now it's all about what you want whether to cache has been made available to the public or is accessible to different users.

Enhanced by Zemanta