Introduce several optimization methods of PHP site performance _php Tutorial

Source: Internet
Author: User
Tags pear ioncube
If it can be used rationally

1:object Code Cache

Each time a request occurs, you need to recompile your object code, if you use the cache, then avoid recompiling, so that your script can be executed faster, improve the performance of PHP site.

The following packages are available:

A) ioncube:http://www.ioncube.com/

B) Zend Encoder:http://www.zend.com/products/zend_safeguard

C) Turckl mmcache:http://freshmeat.net/projects/turck-mmcache/

2: Template system

The template system provides a different form of caching. Content caching. When you have a lot of static data and many pages do not need to reload, the template system is very helpful. The caching system also separates code and HTML, not only to improve the execution time of your codes, but also to make your future maintenance easier and improve the performance of your PHP site.

A) Smarty templates:http://smarty.php.net/

B) Pear templates:http://pear.php.net/package/html_template_it/redirected

C) PHP savant:http://phpsavant.com/yawiki/

3: Distributed Object Caching system

The most common use is memcached.

This system puts the database data in a large pool of memory, which makes your website run fast and optimizes the performance of the PHP site.

4: Set some PHP variables

Variables_order = ' GPC '

REGISTER_ARGC_ARGV = ' Off '

register_globals = ' Off '

Always_populate_raw_post_data = ' Off '

MAGIC_QUOTES_GPC = ' Off '

5:output Compression

Almost all browsers support gzip compression, gzip can reduce the output of 80%, pay the price is about 10% increase in CPU calculation. But what you earn is that not only does the bandwidth decrease, but your page loads quickly and optimizes the performance of your PHP site.

You can open it in php.ini.

Zlib.output_compression = On

Zlib.output_compression_level = (level) may be a number between 1-9, you can set different numbers so that he fits your site. )

If you use Apache, you can also activate the Mod_gzip module, which he is highly customizable.

6: Other

When you use a database, just take the data you need to use, and avoid using a select * from mytable sentence.

The use of indexes is also useful for optimizing the performance of PHP sites.


http://www.bkjia.com/PHPjc/445952.html www.bkjia.com true http://www.bkjia.com/PHPjc/445952.html techarticle If you can reasonably use the 1:object code cache every time a request occurs, you need to recompile your object code, if you use the cache, then avoid the re ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.