Stream is used to increase the response time of images on the server

Source: Internet
Author: User
Previously, I talked about how to use external resources to minimize server load. CSS compresses small files by merging and JavaScript to accelerate server response time.

Previously, I talked about how to use external resources to minimize server load. CSS compresses small files by merging and JavaScript to accelerate server response time, I saw an article on the website loading images in the form of a stream, which is several times faster. MXHR technology is used. MXHR is called Multipart XMLHttpRequest. It allows the client to transmit multiple resources from the server to the client using only one HTTP request. This saves a lot of time, because HTTP requests are time-consuming. In this example, only one HTTP request is made for all images, not one request for each image. Therefore, the loading speed can be increased by 3-5 times theoretically. For the last pure HTML and JS code generation, PHP is also used in the background. Use PHP to read images and convert them to base64 encoding. It should be noted that for the img label src, it not only supports direct image path writing,

Mxhr reduces the number of HTTP requests, but there are also browser restrictions. because xmlhttp requests in IE6 and 7 do not support 3 readyState and do not support images:

Img. src = 'data: image/png; base64, '+ imageData;
The following is an online instance. how to load images using JS + PHP real stream? mxhr php instance

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.