The document discusses REST and HTTP caching. It explains the key principles of REST including client-server architecture, statelessness, cacheability, layered system, and uniform interface. It then discusses how to implement caching and scalability in HTTP, including using expiration headers, cache-control headers, and entity tags to control caching. It notes the importance of caching for performance, scalability, and reducing workload.
2. Sorry for the ugly slide.
There will be others.
Really sorry.
Bengaluru, 20-22 November 2011
3. REST in a nutshell
Bengaluru, 20-22 November 2011
4. 2000
Fielding's dissertation:
REpresentational
State
Transfer
http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
Bengaluru, 20-22 November 2011
5. REST in a nutshell:
1. Client <> Server
Bengaluru, 20-22 November 2011
6. REST in a nutshell:
2. Stateless
Bengaluru, 20-22 November 2011
7. Servers do not keep any
informations the clients uses
during different requests.
Bengaluru, 20-22 November 2011
32. RESTful clients should
be driven by service's
hypermedia controls
Roy Fielding : http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven
Bengaluru, 20-22 November 2011
43. 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
Bengaluru, 20-22 November 2011
44. 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
Bengaluru, 20-22 November 2011
45. The HTTP protocol is awesome,
and lets you return meaningful and
universally-understood status codes
Bengaluru, 20-22 November 2011
53. And meanwhile, at Facebook...
12TB of new data every day
(1 year ago)
500 million users
Bengaluru, 20-22 November 2011
54. And meanwhile, at Google...
1 billion
unique monthly googlers
Bengaluru, 20-22 November 2011
55. via HTTP , baby!
Bengaluru, 20-22 November 2011
56. HTTP in a nutshell:
1. Client <> Server
Bengaluru, 20-22 November 2011
57. HTTP in a nutshell:
2. Stateless
Bengaluru, 20-22 November 2011
58. HTTP in a nutshell:
3. widespread cache spec
http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
Bengaluru, 20-22 November 2011
59. HTTP in a nutshell:
Lao Tze Song using Firefox 6
Company proxy
Great chinese (fire)wall
Reverse proxy
Origin server
4. Layered system
Bengaluru, 20-22 November 2011
60. HTTP in a nutshell:
5. it is the uniform interface
between clients and servers
Bengaluru, 20-22 November 2011
76. HTTP/1.1 200 OK
Host: www.example.com
Expires: Tue, 31 Jan 2011 01:00 GMT
Bengaluru, 20-22 November 2011
77. HTTP/1.1 200 OK
Host: www.example.com
Cache-Control: max-age=60, public
Bengaluru, 20-22 November 2011
78. HTTP/1.1 200 OK
Host: www.example.com
Cache-Control: max-age=60, public
Bengaluru, 20-22 November 2011
79. HTTP/1.1 200 OK
Host: www.example.com
Cache-Control: max-age=60, public
Cacheable for 60 seconds
Bengaluru, 20-22 November 2011
80. HTTP/1.1 200 OK
Host: www.example.com
Cache-Control: max-age=60, public
Cacheable by both local and shared caches
Bengaluru, 20-22 November 2011
81. You can also cache with
validation
(Etags, If-None-Match, ...)
Bengaluru, 20-22 November 2011
82. Why HTTP caching
is so
important?
Bengaluru, 20-22 November 2011
83. Ask yourself:
as a developer, what do I want
on my application?
Bengaluru, 20-22 November 2011
84. Evolve
Loose coupling
Work less
Bengaluru, 20-22 November 2011
85. Evolve
Because you want your platform to extensible
Loose coupling
Work less
Bengaluru, 20-22 November 2011
86. Evolve
Because you want your platform to extensible
Loose coupling
Because you want it to be easy to integrate with, evolve, plug
and mantain
Work less
Bengaluru, 20-22 November 2011
87. Evolve
Because you want your platform to extensible
Loose coupling
Because you want it to be easy to integrate with, evolve, plug
and mantain
Work less
Because every LoC is bug-prone and our man-day is a hard-to-
scale cost
Bengaluru, 20-22 November 2011
139. because caching is bound to the protocol, HTTP, not
to your implementation ( Sf, RoR, Django )
Bengaluru, 20-22 November 2011
140. but hey, you say
Bengaluru, 20-22 November 2011
141. 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 )
Bengaluru, 20-22 November 2011
143. ESI was built for that
http://www.w3.org/TR/esi-lang
Bengaluru, 20-22 November 2011
144. Edge Side Includes
A de facto standard for bla bla bla...
Bengaluru, 20-22 November 2011
145. Edge Side Includes
A de facto standard for bla bla bla...
Server side includes ( not SSI! ) usually handled by the
architecture's ESI processor.
http://www.w3.org/TR/esi-lang
http://www.w3.org/TR/edge-arch