Summary of basic optimization method of PHP website for iphone official website

Source: Internet
Author: User
Tags php website
1. Using gzip

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

With this code, the server compresses all the code that needs to be routed to the client and extracts it in the browser, making the site run faster. This feature can also save traffic to your site's space.

2. Do not misuse JavaScript and Ajax

Use JavaScript and Ajax only when you need it, and never misuse it. Some websites use too many unnecessary Ajax animations, or use Ajax to load useless parts. As a result, JavaScript files become large, and there are actually many other scenarios to implement them.

3. Pictures, header files and HTTP requests

This is the most critical part of this article. The more pictures, external files, and CSS style files The Web page refers to, the more slowly the page is loaded. Take some time to narrow down the picture files and other external files so that they can be loaded faster. In addition, each time a picture and an external file is loaded, an HTTP request is generated, which will delay the load time. You can use the following methods to compress Web page files, JS files, and CSS style files:

Web file: Using gzip, see the first article
JS file: http://www.fmarcia.info/jsmin/test.html This site can effectively reduce the size of JS file
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

Every request to a database slows down the load on the page. Web developers allow this to be difficult to control, but they can be optimized in some detail. For example, when selecting 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 extension

Some people think that saving the JS file as filename.js.php and saving the CSS file as stylesheet.css.php will reduce the load time, but I'm not aware of the difference. Of course, if the speed of your website becomes very slow, you can try this method. Of course, you'll need to load these files with include () in each PHP file.

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

Go to this website to check your own website, it will give you some suggestions on how to optimize the site. I use this feature every time I create a new page.

The above describes the iphone official website PHP website Basic Optimization method Summary, including the official iphone website content, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    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.