16. cool URIs help you
think in term of resources
David Zuelke
PHP.TO.START, July 11 2011 - Turin
17. 2
URIs (bis)
PHP.TO.START, July 11 2011 - Turin
18. REST follows a URI schema
GET /users
POST /users
PUT /users/{id}
DELETE /users/{id}
...
PHP.TO.START, July 11 2011 - Turin
19. REST follows a URI schema
GET /users
POST /users
PUT /users/{id}
DELETE /users/{id}
...
PHP.TO.START, July 11 2011 - Turin
20. what if you change your
URL?
PHP.TO.START, July 11 2011 - Turin
21. Yeah,
client is
broken
PHP.TO.START, July 11 2011 - Turin
22. RESTful clients should
be driven by service's
hypermedia controls
Roy Fielding : http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven
PHP.TO.START, July 11 2011 - Turin
28. loosing meaningful verbs at the protocol level
nothing cacheable by default
PHP.TO.START, July 11 2011 - Turin
29. loosing meaningful verbs at the protocol level
nothing cacheable by default
what about bookmarking?
PHP.TO.START, July 11 2011 - Turin
30. 4
500 is your friend
PHP.TO.START, July 11 2011 - Turin
31. said SOAP
( again )
PHP.TO.START, July 11 2011 - Turin
32. GET /users/300
Host: www.example.com
PHP.TO.START, July 11 2011 - Turin
33. GET /users/300
Host: www.example.com
HTTP/1.1 500 Internal Server Error
Etag: 1234
X-Powered-By: php/5.3
...
The record cannot be found
PHP.TO.START, July 11 2011 - Turin
34. GET /users/300
Host: www.example.com
HTTP/1.1 500 Internal Server Error
Etag: 1234
X-Powered-By: php/5.3
...
The record cannot be found
PHP.TO.START, July 11 2011 - Turin
35. The HTTP protocol is awesome,
and lets you return meaningful and
universally-understood status codes
PHP.TO.START, July 11 2011 - Turin
43. And meanwhile, at Facebook...
12TB of new data every day
(1 year ago)
500 million users
PHP.TO.START, July 11 2011 - Turin
44. And meanwhile, at Google...
1 billion
unique monthly googlers
PHP.TO.START, July 11 2011 - Turin
45. via HTTP , baby!
PHP.TO.START, July 11 2011 - Turin
46. HTTP in a nutshell:
1. Client <> Server
PHP.TO.START, July 11 2011 - Turin
47. HTTP in a nutshell:
2. Stateless
PHP.TO.START, July 11 2011 - Turin
48. HTTP in a nutshell:
3. widespread cache spec
http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
PHP.TO.START, July 11 2011 - Turin
49. HTTP in a nutshell:
Lao Tze Song using Firefox
5
Company proxy
Great chinese (fire)wall
Reverse proxy
Origin server
4. Layered system
PHP.TO.START, July 11 2011 - Turin
50. HTTP in a nutshell:
5. it is the uniform interface
between clients and servers
PHP.TO.START, July 11 2011 - Turin
60. on the server side
PHP.TO.START, July 11 2011 - Turin
61. Caching with
Expiration
(example)
PHP.TO.START, July 11 2011 - Turin
62. HTTP/1.1 200 OK
Host: www.example.com
Expires: 0
PHP.TO.START, July 11 2011 - Turin
63. HTTP/1.1 200 OK
Host: www.example.com
Expires: 0
PHP.TO.START, July 11 2011 - Turin
64. HTTP/1.1 200 OK
Host: www.example.com
Expires: Tue, 31 Jan 2011 01:00 GMT
PHP.TO.START, July 11 2011 - Turin
65. HTTP/1.1 200 OK
Host: www.example.com
Cache-Control: max-age=60, public
PHP.TO.START, July 11 2011 - Turin
66. HTTP/1.1 200 OK
Host: www.example.com
Cache-Control: max-age=60, public
PHP.TO.START, July 11 2011 - Turin
67. HTTP/1.1 200 OK
Host: www.example.com
Cache-Control: max-age=60, public
Cacheable for 60 seconds
PHP.TO.START, July 11 2011 - Turin
68. HTTP/1.1 200 OK
Host: www.example.com
Cache-Control: max-age=60, public
Cacheable by both local and shared caches
PHP.TO.START, July 11 2011 - Turin
69. but hey, you say
PHP.TO.START, July 11 2011 - Turin
70. 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 )
PHP.TO.START, July 11 2011 - Turin