Wednesday, 29 July 2015

Speed up PHP with APC

APC or Alternative PHP Cache, is a free open-source opcode (operation code) caching plugin for PHP. With APC caching your PHP script executions can run more efficiently, by cutting down on dynamic PHP executions.



PHP is a dynamic scripting language, so every time there is a request for a page, the server must first parse the code in your PHP script in order to generate the resulting HTML code seen by a visitor's web-browser.
PHP is ideal for web pages that have content that is constantly updated, since each visitor gets a fresh copy of the page. So for instance if you have your PHP script pulling data from a database, as soon as there is new data in the database, it will automatically be in the generated HTML code for the next visitor requesting that page as well.
In most cases the need to re-run PHP scripts for data that might not have changed in the first place, can be taxing on the server. By implementing APC you cut down on repeat PHP script executions, skipping the parsing and compiling steps. APC stores the opcode, and that is simply executed each time the script is called again.
APC is a PECL module that can be loaded into PHP, but because it operates at the server-level it can not be run on shared hosting servers. If you are on a VPS or dedicated server and are comfortable installing PECL modules, then you can go ahead and install APC yourself.
The last PHP version that had the php_apc extension included in was PHP 5.3. * Newer versions of PHP have replaced APC with php_opcache.

No comments:

Post a Comment