正对这种情况,还有一种处理方法,就是让response分块编码进行传输。response分块编码,可以先传输一部分不需要处理的html代码到客户端,等其他耗时代码执行完毕后再传输另外的html代码。
10年积累的网站制作、网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有安龙免费网站建设让你可以放心的选择与我们合作。
分块编码(chunked encoding)
chunked encoding 是http1.1 才支持编码格式(当然目前没有哪个浏览器不支持1.1了),chunked encoding 与一般的响应区别如下:
- 正常的响应:
- HTTP/1.1 200 OK
- Cache-Control: private, max-age=60
- Content-Length: 75785
- Content-Type: text/html; charset=utf-8
- ..其他response headers
- chunked encoding 响应:
- HTTP/1.1 200 OK
- Cache-Control: private, max-age=60
- Content-Length: 75785
- Content-Type: text/html; charset=utf-8
- Transfer-Encoding: chunked
- ..其他response headers
- chunk #1(这里通常是16进制的数字,标志这个块的大小)
- chunk #2
- chunk #3
- ....