Web front-end optimization Best Practices Server Chapter

Source: Internet
Author: User
Tags flush header iis

Web Front-End optimization Best practices the second part is oriented to the Server. A total of 6 rules of practice are currently in line. "Note, this is the most technical note, view the most original content, also please visit: Exceptional performance:best practices for speeding up Your Web Site"

1. Using CDN (use a Content Delivery network)

The popularization of domestic CDN is not enough. However, we have a unique telecommunications, netcom between the problem, if the optimization for this, basically can receive a CDN or similar effect it (pretend so). "Tin said the domestic CDN use quite a lot, look at the CDN manufacturer's market to know, has not walked into ordinary people's home"

2. Add Expires or Cache-control header (add an Expires or a Cache-control header) each browser has a solution, Apache example "NOTE: The following example is not fine, specific environment and add some adjustments ":ExpiresActive On
ExpiresByType image/gif "modification plus 1 weeks"

LIGHTTPD the Mod_expire module is enabled:

$HTTP["url"] =~ "\.(jpg|gif|png)$" {
   expire.url = ( "" => "access 1 years" )
}

Nginx Example Reference:

location ~* \.(jpg|gif|png)$ {
 if (-f $request_filename) {
    expires   max;
  break;
 }    
}
3. Compressed content (Gzip components)

For most sites, this is a necessary step, can effectively reduce network traffic pressure. Perhaps some people worry about CPU compression on the impact of the CPU, rest assured that the whole bar, it's okay. Nginx Example:

gzip      on;
gzip_types   text/plain text/html text/css ext/javascript;

See In addition:

How does IIS enable Gzip compression? 4. Set Etags (Configure Etags)

For Etag, it may be a place that most web maintainers will overlook. Prior to this series of tuning rules, it is possible that most sites on the Internet have overlooked this issue. Of course, the impact of Etag on most site performance is not significant. Unless it's an RSS-oriented web site. "See a friend criticize say write concisely, and say IE does not support ETag." Specifically: IE support ETag, but use IIS to pay attention to related ETAG bugs. 】

Add: I mean "a lot of sites are not aware of the situation are open Etag, and no site care how to use, consumption of resources and do not know." Not that Etag bad, reasonable use of Etag, can definitely achieve a good profit.

5. Flush the buffer as soon as possible (Flush the buffer Early)

On this one, pondering for a long time, seemingly or asynchronous thinking. Can better enhance the user experience?

6. Use the Get method for Ajax requests (using get-for Ajax Requests)

XMLHttpRequest POST takes two steps, and get takes only one step. However, it is important to note that in IE the maximum processing URL length is 2K.

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.