After using this code, the server will compress all The code needs to be sent to the client and decompressed in the browser to make the website run faster. This feature can also save website space traffic. 2. Don’t abuse Javascript and Ajax. Use Javascript and Ajax only when needed, and never abuse them. Some websites use"/> After using this code, the server will compress all The code needs to be sent to the client and decompressed in the browser to make the website run faster. This feature can also save website space traffic. 2. Don’t abuse Javascript and Ajax. Use Javascript and Ajax only when needed, and never abuse them. Some websites use">

Home  >  Article  >  Backend Development  >  iphone official website summary of basic optimization methods for PHP websites

iphone official website summary of basic optimization methods for PHP websites

WBOY
WBOYOriginal
2016-07-29 08:38:521433browse

1. Use GZip

Add the following code to the top of each PHP page:

php ob_start("ob_gzhandler");?>

After using this code, the server will compress all the data that needs to be sent to the client. code and decompress it in the browser, making the website run faster. This feature can also save website space traffic.

2. Don’t abuse Javascript and Ajax

Use Javascript and Ajax only when necessary, and never abuse them. Some websites use too many unnecessary Ajax animations, or use Ajax to load useless parts. In this way, the Javascript file will become very large, but in fact there are many other solutions to achieve these functions.

3. Pictures, header files and HTTP requests

 This is the most critical part of this article. The more images, external files and CSS style files that a webpage references, the slower the webpage will load. Take the time to make image files and other external files smaller so they load faster. In addition, every time you load images and external files, an HTTP request is generated, which will definitely delay the loading time. You can use the following methods to compress webpage files, JS files and CSS style files:

Webpage files: Use GZip, please see the first article
JS files: http://www.fmarcia.info/jsmin/ test.html This website can effectively reduce the size of JS files
CSS files:http://www.cssdrive.com/index.php/main/csscompressor/ This website can reduce the size of CSS files

4. Limit the number of MySQL queries

 Every request to the database will slow down the loading speed of the webpage. Web developers make it difficult to control this, but it can be optimized in some subtle ways. For example, when selecting database records, instead of using the following code:

SELECT * FROM database

instead use:

SELECT id, name, date, author, etc, blah, blah FROM database

 This will consume less Query time and reduce server load.

5 Notice the difference. Of course, if your website's speed becomes very slow, you can try this method. Of course, you need to use include() in each PHP file to load these files.

6. http://www.websiteoptimization.com/

Go to this website to test your own website. It will give you some suggestions on how to optimize your website. I use this feature every time I create a new webpage

.

The above has introduced a summary of the basic optimization methods of PHP website for the iphone official website, including the content of the iphone official website. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn