Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ccb06c

Browse files
committed
加载策略 之 HTTP分块 翻译完毕
1 parentb87ce14 commit2ccb06c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

‎chapter8.markdown‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,52 @@ script元素会阻塞页面的下载。浏览器会同时下载好几个组件
681681
</body>
682682
</html>
683683

684+
###HTTP分块
685+
686+
HTTP协议支持“分块编码”。它允许将页面分成一块一块发送。所以如果你有一个很复杂的页面,你不需要将那些每个站都多多少少会有的(静态)头部信息也等到所有的服务端工作都完成后再开始发送。
687+
688+
一个简单的策略是在组装页面其余部分的时候将页面\<head\>的内容作为第一块发送。也就是像这样子:
689+
690+
<!doctype html>
691+
<html>
692+
<head>
693+
<title>My App</title>
694+
</head>
695+
<!-- end of chunk #1 -->
696+
<body>
697+
...
698+
<script src="all_20100426.js"></script> </body>
699+
</html>
700+
<!-- end of chunk #2 -->
701+
702+
这种情况下可以做一个简单的发动,将JavaScript移回\<head\>,随着第一块一起发送。
703+
704+
这样的话可以让服务器在拿到head区内容后就开始下载脚本文件,而此时页面的其它部分在服务端还尚未就绪:
705+
706+
<!doctype html>
707+
<html>
708+
<head>
709+
<title>My App</title>
710+
<script src="all_20100426.js"></script> </body>
711+
</head>
712+
<!-- end of chunk #1 -->
713+
<body>
714+
...
715+
</html>
716+
<!-- end of chunk #2 -->
717+
718+
719+
720+
721+
722+
723+
724+
725+
726+
727+
728+
729+
730+
731+
732+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp