@brianclozel
#Devoxx
HTTP/2 for the web developer
Brian Clozel
Pivotal Software
Slide 2
Slide 2 text
@brianclozel
#Devoxx
• Spring Framework committer
• https://spring.io lead developer
Slide 3
Slide 3 text
HTTP/2 is about
solving latency issues
Slide 4
Slide 4 text
HTTP/2 basics in 6 steps
Slide 5
Slide 5 text
#1 - a single TCP connection
Slide 6
Slide 6 text
#2 - multiple Streams
Slide 7
Slide 7 text
#3 - binary framing
Slide 8
Slide 8 text
Client Server
Stream: 3
HEADERS
GET /java
Stream: 5
DATA
Stream: 5
HEADERS
POST /devoxx
Stream: 5
DATA
Stream: 3
HEADERS
Stream: 3
DATA
Stream: 5
HEADERS
Stream: 3
DATA
How should we adapt?
• What about « front-end optimizations »?
• undo concatenation
• keep gzipping content
• use ETags, Cache-Control directives
• use JS module loaders
Slide 14
Slide 14 text
HTTP/2 new,
optional features?
Slide 15
Slide 15 text
HTTP/2 Server Push!
Slide 16
Slide 16 text
Client Server
Stream: 3
HEADERS
GET /index.html
Stream: 8
RST_STREAM
CANCEL
Stream: 10
RST_STREAM
CANCEL
Stream: 3
PUSH_PROMISE
Promised Stream: 8
GET /main.css
Stream: 8
HEADERS
Stream: 3
PUSH_PROMISE
Promised Stream: 10
GET /script.js
Slide 17
Slide 17 text
Why not send the
main response first?
Slide 18
Slide 18 text
« The server SHOULD send PUSH_PROMISE (Section 6.6)
frames prior to sending any frames that reference the promised
responses. This avoids a race where clients issue requests
prior to receiving any PUSH_PROMISE frames. »
Slide 19
Slide 19 text
Client Server
Stream: 3
HEADERS
GET /index.html
Stream: 3
PUSH_PROMISE
Promised Stream: 8
GET /main.css
Stream: 3
HEADERS
Stream: 3
DATA
Stream: 5
HEADERS
GET /main.css
[Parsing HTML…]
!!!
Slide 20
Slide 20 text
Who knows best, then?
• Server-side application
• HTML structure
• number/size of resources
• HTTP client
• heuristics
• state of cache
• CPU, battery, local network
• Us, developers?