Http:2.0 101 introduction (workshop) - Bastian Hofmann
- 50. GET /home HTTP/1.1
Host: www.researchgate.net
pragma: no-cache
dnt: 1
accept-encoding: gzip, deflate, sdch
accept-language: de-DE,de;q=0.8,en-
US;q=0.6,en;q=0.4
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X
10_10_4) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/46.0.2478.0 Safari/537.36
accept: text/html,application/xhtml
+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
cache-control: no-cache
cookie: …
- 85. HTTP/1.1 200 OK
Content-Type: text/html
<html>
<head>
<link href="main.css" >
<link href="profile.css" >
<script src="library.js" />
<script src="app.js" />
<script>
// some JS
</script>
</head>
<body>
- 147. HTTP/1.1 200 OK
Content-Type: text/html
<html>
<head>
<styles>
… your critical css
</styles>
</head>
<body>
<div>content</div>
load main.css async
set cookie that other css was loaded
</body>
</html>
- 149. HTTP/1.1 200 OK
Content-Type: text/html
<html>
<head>
<link href="main.css" >
// loaded from cache
</head>
<body>
<div>content</div>
</body>
</html>
- 152. Browser Server
GET css & js
HTTP/1.1 200 OK
Content-Type: text/html
<html>
<head><link ..><script ..>
GET /foo.html
</head><body></body></html>
- 176. Browser Server
Push CSS & JS
:status: 200
Content-Type: text/html
<html>
<head><link ..><script ..>
</head><body></body></html>
GET /foo.html
- 177. spdy.createServer(options, function(req, res) {
// push JavaScript asset (/main.js) to the client
res.push(
'/main.js',
{'content-type': ‚application/javascript'},
function(err, stream) {
stream.end('alert("hello from push stream!")');
}
);
// write main response body and terminate stream
res.end(
'Hello World! <script src=��/main.js"></script>'
);
}).listen(443);
https://www.igvita.com/2013/06/12/innovating-with-http-2.0-server-push/