----------------------------------------------
1. Request data
There are 5 commonly used techniques for requesting data from the server: Xmlhttprequest,dynamic script tag insertion (dynamic script tag insertion), Iframes,comet,multiparty XHR (Multi-part XHR);
(1) XHR: Generally with get and post requests, when the URL parameter length exceeds 2048 characters, only use post to submit data, because IE restricts the length of the URL, too long will cause the request is truncated;
(2) Dynamic script insertion: Dynamic script insertion provides less control than it can be; You cannot send a message header by request; The parameter can only be passed by a get method; You cannot set the request timeout or retry; in fact, you don't need to know if it failed. You must wait until all data is returned before you can access them. ----namely: JSONP
(3) Image tag simulation, usually just send data to the server, do not need a lot of return;
2: Caching (Cache)
(1) On the server side, set the HTTP header to ensure that the return message will be cached in the browser;
(2) On the client side, cache the acquired data locally; Do not request the same data multiple times;
The first technology is easiest to set up and maintain, and the second gives you the greatest degree of control;
Set HTTP headers;
If you want AJAX messages to be cached by the browser, you must initiate a GET request, and you must send the correct HTTP in the appropriate message, and the expires header tells the browser how long the response message should be cached;
--------------------------------------------------------------------------------------------------------------- -------------------------------------
When a Web browser requests a resource, it usually sends a accept-encoding HTTP header to let the Web server know what type of encoding is supported by the transport, which allows the document to compress to get faster speed, thereby improving the user experience ; accept-encoding Range: Gzip,compress,deflate and identity
--------------------------------------------------------------------------------------------------------------- --------------------------------------
Use content delivery Network CDN;
< finish >
High-performance JavaScript programming (repetition 2)