CachingHypermedia   APIs   By Tim Stokes
Watch the video with slide                         synchronization on InfoQ.com!                      http://www.infoq.com...
Presented at QCon San Francisco                          www.qconsf.comPurpose of QCon- to empower software development by...
A very brief history  of HypermediaThe Big Bang, 13.75 Billion Years Ago
Various Events…
Hypermedia      Ted Nelson, 1963
HTML   HTTPTim Berners-Lee (and friends), 1991
REST (HTTP 1.1)Roy Fielding (and his posse), 1999
By Paul Downey, http://www.flickr.com/photos/psd/    The Hypermedia Dark Ages, 2000-2005
POST /query HTTP/1.1            table=stick&status=thrown   The RESTful years, 2005-2009
AffordancesMike Amundsen, circa 2010…
HTTP withHypermedia  +cachability     2012…
Choosing a             Caching Strategy                TheoreticalNatural                                        Managed  ...
Natural Caching Behavior 1         Transfer state in the body not the URI
POST /box/open   GET /box
POST /boxstate=openGET /box
Natural Caching Behavior 2         Un-Safe Requests Invalidate Cache
/car8/mycar
/car8
/car8
Natural Caching Behavior 3             Related resources can    be Invalidated.
POST         1.  /container is                    invalidated                                   2.  303 + Location:/contai...
DELETE               1.  /container/item8/container/item8       is invalidated                                          2....
Natural Caching Behavior 4            Beware of Summaries    and Bundles
GET /lamp/1    1         POST /lamp/1    1                             power=onGET /lampslinks… /lamp/1, /lamp/2, /lamp/3,...
RESOURCE DESIGN NOTES:•    The URI should not carry state•    Symmetry between state in and out•    One way to get each pi...
Natural Caching Behavior 5            Cached responses can be bound to specific contexts beyond the         URI.
GET /boxAccept-Language: EN                                                                                             SY...
Natural Caching Behavior 6             There is no guaranteeyou will see the latest    representation
Relativity
PUT /lampON	                  OR              GET /lamp
Managed Caching Behavior 1                Use Etags with   conditional GETs
GET /dog6      ETag: 6                                                                             SYSTEM      GET /dog If...
GET /dog6      ETag: 6                                                                             SYSTEM      GET /dog If...
Managed Caching Behavior 2  Let Caches know about all resourcesthat are invalid in the response to a state       change.
Mark Nottingham’sLinked Cache Invalidation Drafthttp://tools.ietf.org/html/draft-nottingham-linked-cache-inv-03	  
Relying on these Caching       Behaviors in Practice                  •    Compliance to HTTP 1.1•    Interpretation of HT...
Approach                  and granularity•  Design the shape                    of your resources carefully.•  Target TTL ...
What’s Next?                        HTTP 2.0http://tools.ietf.org/wg/httpbis/charters	  
The End
Caching Hypermedia APIs
Upcoming SlideShare
Loading in …5
×

Caching Hypermedia APIs

1,471 views

Published on

Video and slides synchronized, mp3 and slide download available at http://bit.ly/YKORol.

Tim Stokes discusses various URI caching strategies providing real life examples relying on some of the natural behaviors that are built into the HTTP 1.1 protocol. Filmed at qconsf.com.

Tim Stokes is the Applications Architect at FamilySearch.org, a not for profit organization that provides free resources for people to research their family tree. Prior to FamilySearch, Tim worked in London and Sydney with a number of companies including BT, Citigroup, Royal and SunAlliance, Press Co, Prudential, GM Vauxhall, The London Stock Exchange, Qantas, AMP and Intuit Australia.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,471
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Caching Hypermedia APIs

  1. 1. CachingHypermedia APIs By Tim Stokes
  2. 2. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /Caching-Hypermedia-API InfoQ.com: News & Community Site• 750,000 unique visitors/month• Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese)• Post content from our QCon conferences• News 15-20 / week• Articles 3-4 / week• Presentations (videos) 12-15 / week• Interviews 2-3 / week• Books 1 / month
  3. 3. Presented at QCon San Francisco www.qconsf.comPurpose of QCon- to empower software development by facilitating the spread ofknowledge and innovationStrategy - practitioner-driven conference designed for YOU: influencers ofchange and innovation in your teams- speakers and topics driving the evolution and innovation- connecting and catalyzing the influencers and innovatorsHighlights- attended by more than 12,000 delegates since 2007- held in 9 cities worldwide
  4. 4. A very brief history of HypermediaThe Big Bang, 13.75 Billion Years Ago
  5. 5. Various Events…
  6. 6. Hypermedia Ted Nelson, 1963
  7. 7. HTML HTTPTim Berners-Lee (and friends), 1991
  8. 8. REST (HTTP 1.1)Roy Fielding (and his posse), 1999
  9. 9. By Paul Downey, http://www.flickr.com/photos/psd/ The Hypermedia Dark Ages, 2000-2005
  10. 10. POST /query HTTP/1.1 table=stick&status=thrown The RESTful years, 2005-2009
  11. 11. AffordancesMike Amundsen, circa 2010…
  12. 12. HTTP withHypermedia +cachability 2012…
  13. 13. Choosing a Caching Strategy TheoreticalNatural Managed TTL ETags Other Practical
  14. 14. Natural Caching Behavior 1 Transfer state in the body not the URI
  15. 15. POST /box/open GET /box
  16. 16. POST /boxstate=openGET /box
  17. 17. Natural Caching Behavior 2 Un-Safe Requests Invalidate Cache
  18. 18. /car8/mycar
  19. 19. /car8
  20. 20. /car8
  21. 21. Natural Caching Behavior 3 Related resources can be Invalidated.
  22. 22. POST 1.  /container is invalidated 2.  303 + Location:/container /container/item8 or 2. Content-Location: /container/item8
  23. 23. DELETE 1.  /container/item8/container/item8 is invalidated 2. 303 + Location: /container or 2. Content-Location: /container
  24. 24. Natural Caching Behavior 4 Beware of Summaries and Bundles
  25. 25. GET /lamp/1 1 POST /lamp/1 1 power=onGET /lampslinks… /lamp/1, /lamp/2, /lamp/3, /lamp/4,/lamp/5, /lamp/6, etc…GET /all-on-lamps 5 1 3
  26. 26. RESOURCE DESIGN NOTES:•  The URI should not carry state•  Symmetry between state in and out•  One way to get each piece of state•  Beware of Summaries and Bundles
  27. 27. Natural Caching Behavior 5 Cached responses can be bound to specific contexts beyond the URI.
  28. 28. GET /boxAccept-Language: EN SYSTEM box Cache-Control: max-age=3600 Vary: Accept-LanguageGET /boxAccept-Language: FR boîte Cache-Control: max-age=3600 Vary: Accept-Language
  29. 29. Natural Caching Behavior 6 There is no guaranteeyou will see the latest representation
  30. 30. Relativity
  31. 31. PUT /lampON   OR GET /lamp
  32. 32. Managed Caching Behavior 1 Use Etags with conditional GETs
  33. 33. GET /dog6 ETag: 6 SYSTEM GET /dog If-None-Match: 6 ✓ 304
  34. 34. GET /dog6 ETag: 6 SYSTEM GET /dog If-None-Match: 6 3 200 ETag: 3
  35. 35. Managed Caching Behavior 2 Let Caches know about all resourcesthat are invalid in the response to a state change.
  36. 36. Mark Nottingham’sLinked Cache Invalidation Drafthttp://tools.ietf.org/html/draft-nottingham-linked-cache-inv-03  
  37. 37. Relying on these Caching Behaviors in Practice •  Compliance to HTTP 1.1•  Interpretation of HTTP 1.1•  Implementation variance•  Intermediaries
  38. 38. Approach and granularity•  Design the shape of your resources carefully.•  Target TTL in the Agent first for best natural caching invalidation.•  Use, per request, Agent other request header to trigger caching strategies.•  ETags as second level after TTL.
  39. 39. What’s Next? HTTP 2.0http://tools.ietf.org/wg/httpbis/charters  
  40. 40. The End

×