1. Use gzip
Add the following code at the top of each PHP page:
? php Ob_start ("Ob_gzhandler");? >
Using this code, the server compresses all the code that needs to be delivered to the client and extracts it in the browser, which makes the Web site run faster. This function can also save the site space traffic.
2, do not misuse JavaScript and Ajax
Use JavaScript and Ajax only when needed, and never abuse them. Some sites use too much unnecessary Ajax animations, or use Ajax to load unwanted parts. As a result, JavaScript files can become very large, but there are many other scenarios to implement these functions.
3, picture, header file and HTTP request
This is the most critical part of this article. The more pictures, external files, and CSS style files that are referenced by a Web page , the slower the page loads. Take the time to shrink the picture files and other external files so that they can be loaded faster. In addition, each time a picture and external file is loaded, an HTTP request is generated, which must delay the load time. You can use the following methods to compress Web page files, JS files, and CSS style files:
Web page files: Using gzip, see the first article
JS file:http://www.fmarcia.info/jsmin/test.html This site can effectively reduce the size of JS files
CSS file:http://www.cssdrive.com/index.php/main/csscompressor/ This site can reduce the size of the CSS file
4, limit the number of MySQL queries
Each request to the database slows down the load on the Web page . Web developers allow it to be difficult to control, but they can be optimized in a number of detail areas. For example, when you select a database record, do not use the following code:
SELECT * FROM Database
Instead use:
SELECT ID, name, date, author, etc, blah, blah from database
This consumes less query time and reduces the load on the server.
5,. PHP name extension
Some people think that the JS file is saved as filename.js. php and saving CSS files as stylesheet.css.php will reduce the time to load, but I'm not aware of the difference. Of course, if your site slows down, you can try this method. Of course, you need to use include () in each PHP file to load the files.
6, http://www.websiteoptimization.com/
Go to this site to test your own site, it will give you some advice on how to optimize the site. I use this feature every time I create a new page .