141
Alessandro Nadalin | NAMSHI.com http://end.of.the.road?

HTTP colon slash slash: the end of the road?

Embed Size (px)

DESCRIPTION

Presentation given at the International PHP conference in Mainz, October 2012, dealing with a bit of history about the HTTP protocol, SPDY and the future (HTTP/2.0).

Citation preview

Alessandro Nadalin | NAMSHI.com

http://end.of.the.road?

AGENDA

. History of HTTP. Hidden features

. HTTP/2.0. SPDY

HTTP/X.Y ?

Web development?

Web development?

WWW

Web development?

WWW

Clients

Web development?

WWW

Clients

Servers

Web development?

WWW

Clients

Server

M2M

Servers

Web development?

WWW

Clients

Servers

M2M

ServersAutomation

Any user can easilyinteract with a

Webpage.

( except my mom )

What about machines?

They need rules.

They need rules.

verbs

They need rules.

verbs

domains

They need rules.

verbs

domains

workflows

They need rules.

verbs

domains

workflows

logic

They need rules.

verbs

domains

workflows

logic

constraints

PROTOCOLS

HTTP/0.9

HTTP/0.9(1991)

HTTP/1.0

Tim Berners-Lee

Roy Fielding

GET

separate connections

POST

HEAD

1996

HTTP/1.1

Tim Berners-Lee

Roy Fielding

GET

separate connections

POST

HEAD

1996TRACE

OPTIONS

PUT

DELETE

PATCH

DIFF

Domain Application Protocol

CACHEhttp://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

CACHE CHANNELS

304 Not modified

EXPIRES

SCALABILITY

MAX-AGE

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cc="http://purl.org/syndication/cache-channel"> <title>Invalidations for www.example.org</title> <id>http://admin.example.org/events/</id> <link rel="self" href="http://admin.example.org/events/current"/> <link rel="prev-archive" href="http://admin.example.org/events/archive/1234"/> <updated>2007-04-13T11:23:42Z</updated> <author> <name>Administrator</name> <email>[email protected]</email> </author> <cc:precision>60</cc:precision> <cc:lifetime>2592000</cc:lifetime> <entry> <title>stale</title> <id>http://admin.example.org/events/1124</id> <updated>2007-04-13T11:23:42Z</updated> <link href="urn:uuid:50D3565C-97A8-40E1-A5C8-CFA070166FEF"/> <cc:stale/> </entry> <entry> <title>stale</title> <id>http://admin.example.org/events/1125</id> <updated>2007-04-13T10:31:01Z</updated> <link href="http://www.example.org/img/123.gif" type="image/gif"/> <link href="http://www.example.org/img/123.png" type="image/png"/> <cc:stale/> </entry> </feed>

GET /users/1 HTTP/1.1Host: example.com

HTTP/1.1 200 OkEtag: 123abc

GET /users/1 HTTP/1.1Host: example.comIf-None-Match: 123abc

HTTP/1.1 304 Not Modified

POST /users/1 HTTP/1.1Host: example.comEtag: 123abcdefgh...

HTTP/1.1 412Precondition Failed

GET /users/1 HTTP/1.1Host: example.com

HTTP/1.1 200 OkCache-Control: max-age=60

GET /users/1 HTTP/1.1Host: example.com

FOR FREE

and here are a few ways to do so, using

expiration

validation

invalidation

Expiration

GET / HTTP/1.1Host: www.example.comExpires: 0

GET / HTTP/1.1Host: www.example.comExpires: 0

GET / HTTP/1.1Host: www.example.comExpires: Tue, 15 Nov 1994 01:00 GMT

GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public

GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public

GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public

Cacheable for 60 seconds

GET / HTTP/1.1Host: www.example.comCache-Control: max-age=60, public

Cacheable by both local and shared caches

GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600

GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600

fault-tolerant

GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600

available during downtime

GET / HTTP/1.1Host: www.example.comCache-Control: stale-if-error=600, stale-while-revalidate=600

available during revalidation

Validation

GET / HTTP/1.1Host: www.example.comEtag: 1234

GET / HTTP/1.1Host: www.example.comEtag: 1234

an identifier for your response

GET / HTTP/1.1Host: www.example.comIf-None-Match: 1234

the browsers asks you if it has been modified

Conditional requests

Relax

Calculating an Etag is cheaper than generating a full MVC response

HTTP/1.1 304 Not Modified

GET / HTTP/1.1Host: www.example.comLast-Modified: Tue, 15 Jan 2011 12:00:00 GMT

GET / HTTP/1.1Host: www.example.comLast-Modified: Tue, 15 Jan 2011 12:00:00 GMT

tell the client about the latest change

GET / HTTP/1.1Host: www.example.comIf-Modified-Since: Tue, 15 Jan 2011 12:00:00 GMT

the client asks you if it has been modified since the last time

Conditional requests

Relax

Calculating a date is cheaper than retrieving an entire object

HTTP/1.1 304 Not Modified

Invalidation

The web is not meant for invalidating data.

Server should not be able to keep clients' state, otherwise they wont scale well.

That's why long-polling and endless connections haven't had big success dealing with caching.

but hey, you say

HTTP's cache fails when dealing with really dynamic pages, because consumers will always have to hit the

origin server, although a part of the page would be cacheable ( header and footer, for example )

Nope

Nope

ESI was built for thathttp://www.w3.org/TR/esi-lang

HInclude was built for thathttp://mnot.github.com/hinclude/

So what does HTTP cache is meant to solve?

Less work

because the hard work is delegated to the browser/proxy

http://www.flickr.com/photos/snakphotography/5004775320/sizes/o/in/photostream/

evolve

because cache is abstracted from the application

loose coupling

because caching is bound to the protocol, HTTP, not to your implementation ( Sf, RoR, Django )

it all started

21

years

ago

Damn.

HTTP/2.0

Nothing to see here.

SPDY

You're already using it

HTTP on steroids

Requests prioritization

Client Server

Client Server

Client Server

Client Server

Compression

Extended compression

Multiplexing

Client Server

R/R model

Client Server

R/R model

Client Server

R/R model

Client Server

Pipelining

Client Server

Pipelining

Client Server

Multiplexing

Client Server

Multiplexing

Client Server

Multiplexing

Server push

Result?

SPDY

SPDY

HTTP

Not-so-side effect?

13 years later...

HTTP/2.0

Based on?

SPDYhttp://lists.w3.org/Archives/Public/ietf-http-wg/2012OctDec/0004.html

http://www.slideshare.net/mnot/what-http20-will-do-for-you

Which is based on?

HTTP/1.1

SPDY doesnt change the protocol,it just changes the way messages are

exchanged over the wire

Semantics are the same.

Workflows are the same.

Verbs are the same.

The interface is the same.

And HTTP/1.1 is based on?

HTTP/1.0

15

damn

years

Ago

PERIOD.

An architecture that lasts 20 years is possible.

( REST )

You?

Alex Nadalin

Alex Nadalinodino.org

Alex Nadalin

@_odino_

odino.org

Alex Nadalin

@_odino_

odino.org

Alex Nadalin

@_odino_

odino.org

Alex Nadalin

@_odino_

odino.org DXB

Alex Nadalin

@_odino_

odino.org DXB

We're hiring!

In Dubai.

In Dubai.

[email protected]

In Dubai.

[email protected]

@_odino_

In Dubai.

[email protected]

@_odino_

TALK TO ME!