SlideShare una empresa de Scribd logo
1 de 41
Caching
Hypermedia
   APIs

   By Tim Stokes
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
Presented at QCon San Francisco
                          www.qconsf.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
 - practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
A very brief history
  of Hypermedia



The Big Bang, 13.75 Billion Years Ago
Various Events…
Hypermedia





      Ted Nelson, 1963
HTML


   HTTP

Tim 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
Affordances





Mike Amundsen, circa 2010…
HTTP with

Hypermedia

  +cachability


     2012…
Choosing a
             Caching Strategy

                Theoretical

Natural





                                        Managed

            TTL

                    ETags

                              Other

                    Practical
Natural Caching Behavior 1

         

Transfer state in the
 body not the URI
POST /box/open




   GET /box
POST /box
state=open




GET /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:

/container

                    /container/item8

               

                    or

               

               2.

 Content-Location:
                    /container/item8
DELETE               1.  /container/item8
/container/item8

       is invalidated


                     

                     2. 303 + Location:
                        

 /container

                     

                           or

                     

                     2.

 Content-Location:
                           /container
Natural Caching Behavior 4

            

Beware of Summaries
    and Bundles
GET /lamp/1

    1

         POST /lamp/1    1

                             power=on


GET /lamps
links… /lamp/1, /lamp/2, /lamp/3, /lamp/4,
/lamp/5, /lamp/6, etc…


GET /all-on-lamps

                       5

         1

                 3
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
Natural Caching Behavior 5

            

Cached responses can
 be bound to specific
 contexts beyond the
         URI.
GET /box
Accept-Language: EN





                                                

                                             SYSTEM
   box

     Cache-Control: max-age=3600

             Vary: Accept-Language


GET /box
Accept-Language: FR




        

   boîte
             Cache-Control: max-age=3600

             Vary: Accept-Language
Natural Caching Behavior 6

             

There is no guarantee
you will see the latest
    representation
Relativity
PUT /lamp

ON

	
  
                OR





              GET /lamp
Managed Caching Behavior 1

            

    Use Etags with
   conditional GETs
GET /dog


6

      ETag: 6





                                        

                                     SYSTEM
      GET /dog If-None-Match: 6 




✓        304
GET /dog


6

      ETag: 6





                                        

                                     SYSTEM
      GET /dog If-None-Match: 6 


3

      200 ETag: 3
Managed Caching Behavior 2

  Let Caches know
 about all resources
that are invalid in the
 response to a state
       change.
Mark Nottingham’s

Linked Cache Invalidation Draft

http://tools.ietf.org/html/draft-nottingham-linked-cache-inv-03



	
  
Relying on these Caching
       Behaviors in Practice 

                 

•    Compliance to HTTP 1.1

•    Interpretation of HTTP 1.1

•    Implementation variance

•    Intermediaries
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.
What’s Next?

                        

HTTP 2.0

http://tools.ietf.org/wg/httpbis/charters

	
  
The 

End

Más contenido relacionado

Similar a Caching Hypermedia APIs

2010 AIRI Petabyte Challenge - View From The Trenches
2010 AIRI Petabyte Challenge - View From The Trenches2010 AIRI Petabyte Challenge - View From The Trenches
2010 AIRI Petabyte Challenge - View From The Trenches
George Ang
 
Building a Distributed File System for the Cloud-Native Era
Building a Distributed File System for the Cloud-Native EraBuilding a Distributed File System for the Cloud-Native Era
Building a Distributed File System for the Cloud-Native Era
Alluxio, Inc.
 
ASPECT WP2 presentation
ASPECT WP2 presentationASPECT WP2 presentation
ASPECT WP2 presentation
Joris Klerkx
 
Container Mythbusters
Container MythbustersContainer Mythbusters
Container Mythbusters
inside-BigData.com
 

Similar a Caching Hypermedia APIs (20)

2010 AIRI Petabyte Challenge - View From The Trenches
2010 AIRI Petabyte Challenge - View From The Trenches2010 AIRI Petabyte Challenge - View From The Trenches
2010 AIRI Petabyte Challenge - View From The Trenches
 
The Highs and Lows of Stateful Containers
The Highs and Lows of Stateful ContainersThe Highs and Lows of Stateful Containers
The Highs and Lows of Stateful Containers
 
ResourceSync Tutorial from Open Repositories 2013
ResourceSync Tutorial from Open Repositories 2013ResourceSync Tutorial from Open Repositories 2013
ResourceSync Tutorial from Open Repositories 2013
 
Spectra Logic's BlackPearl Developers Summit 2016
Spectra Logic's BlackPearl Developers Summit 2016Spectra Logic's BlackPearl Developers Summit 2016
Spectra Logic's BlackPearl Developers Summit 2016
 
Building a digital repository for the NAi
Building a digital repository for the NAiBuilding a digital repository for the NAi
Building a digital repository for the NAi
 
Building a Distributed File System for the Cloud-Native Era
Building a Distributed File System for the Cloud-Native EraBuilding a Distributed File System for the Cloud-Native Era
Building a Distributed File System for the Cloud-Native Era
 
Containerized Storage for Containers: Why, What and How OpenEBS Works
Containerized Storage for Containers:  Why, What and How OpenEBS WorksContainerized Storage for Containers:  Why, What and How OpenEBS Works
Containerized Storage for Containers: Why, What and How OpenEBS Works
 
Persistent Storage with Kubernetes in Production
Persistent Storage with Kubernetes in ProductionPersistent Storage with Kubernetes in Production
Persistent Storage with Kubernetes in Production
 
Persistent Storage with Kubernetes in Production
Persistent Storage with Kubernetes in ProductionPersistent Storage with Kubernetes in Production
Persistent Storage with Kubernetes in Production
 
Using Fedora Commons To Create A Persistent Archive
Using Fedora Commons To Create A Persistent ArchiveUsing Fedora Commons To Create A Persistent Archive
Using Fedora Commons To Create A Persistent Archive
 
ASPECT WP2 presentation
ASPECT WP2 presentationASPECT WP2 presentation
ASPECT WP2 presentation
 
Container Mythbusters
Container MythbustersContainer Mythbusters
Container Mythbusters
 
APTrust CNI Seattle April 2015
APTrust CNI Seattle April 2015APTrust CNI Seattle April 2015
APTrust CNI Seattle April 2015
 
Kubernetes I Deep Dive.pptx
Kubernetes I Deep Dive.pptxKubernetes I Deep Dive.pptx
Kubernetes I Deep Dive.pptx
 
Sword 2007 06 22
Sword 2007 06 22Sword 2007 06 22
Sword 2007 06 22
 
ApacheCon Europe 2012 -Big Search 4 Big Data
ApacheCon Europe 2012 -Big Search 4 Big DataApacheCon Europe 2012 -Big Search 4 Big Data
ApacheCon Europe 2012 -Big Search 4 Big Data
 
Alfresco tuning part2
Alfresco tuning part2Alfresco tuning part2
Alfresco tuning part2
 
Sock Puppets: Growing Your Puppet Codebase
Sock Puppets: Growing Your Puppet CodebaseSock Puppets: Growing Your Puppet Codebase
Sock Puppets: Growing Your Puppet Codebase
 
Sock puppets
Sock puppetsSock puppets
Sock puppets
 
CoreOS automated MySQL Cluster Failover using Galera Cluster
CoreOS automated MySQL Cluster Failover using Galera ClusterCoreOS automated MySQL Cluster Failover using Galera Cluster
CoreOS automated MySQL Cluster Failover using Galera Cluster
 

Más de C4Media

Más de C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Caching Hypermedia APIs

  • 1. Caching Hypermedia APIs By Tim Stokes
  • 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. Presented at QCon San Francisco www.qconsf.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. A very brief history of Hypermedia The Big Bang, 13.75 Billion Years Ago
  • 6. Hypermedia Ted Nelson, 1963
  • 7. HTML HTTP Tim Berners-Lee (and friends), 1991
  • 8. REST (HTTP 1.1) Roy Fielding (and his posse), 1999
  • 9. By Paul Downey, http://www.flickr.com/photos/psd/ The Hypermedia Dark Ages, 2000-2005
  • 10. POST /query HTTP/1.1 table=stick&status=thrown The RESTful years, 2005-2009
  • 12. HTTP with Hypermedia +cachability 2012…
  • 13. Choosing a Caching Strategy Theoretical Natural Managed TTL ETags Other Practical
  • 14. Natural Caching Behavior 1 Transfer state in the body not the URI
  • 15. POST /box/open GET /box
  • 17. Natural Caching Behavior 2 Un-Safe Requests Invalidate Cache
  • 18.
  • 20. /car8
  • 21. /car8
  • 22. Natural Caching Behavior 3 Related resources can be Invalidated.
  • 23. POST 1.  /container is invalidated 2.  303 + Location: /container /container/item8 or 2. Content-Location: /container/item8
  • 24. DELETE 1.  /container/item8 /container/item8 is invalidated 2. 303 + Location: /container or 2. Content-Location: /container
  • 25. Natural Caching Behavior 4 Beware of Summaries and Bundles
  • 26. GET /lamp/1 1 POST /lamp/1 1 power=on GET /lamps links… /lamp/1, /lamp/2, /lamp/3, /lamp/4, /lamp/5, /lamp/6, etc… GET /all-on-lamps 5 1 3
  • 27. 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
  • 28. Natural Caching Behavior 5 Cached responses can be bound to specific contexts beyond the URI.
  • 29. GET /box Accept-Language: EN SYSTEM box Cache-Control: max-age=3600 Vary: Accept-Language GET /box Accept-Language: FR boîte Cache-Control: max-age=3600 Vary: Accept-Language
  • 30. Natural Caching Behavior 6 There is no guarantee you will see the latest representation
  • 32. PUT /lamp ON   OR GET /lamp
  • 33. Managed Caching Behavior 1 Use Etags with conditional GETs
  • 34. GET /dog 6 ETag: 6 SYSTEM GET /dog If-None-Match: 6 ✓ 304
  • 35. GET /dog 6 ETag: 6 SYSTEM GET /dog If-None-Match: 6 3 200 ETag: 3
  • 36. Managed Caching Behavior 2 Let Caches know about all resources that are invalid in the response to a state change.
  • 37. Mark Nottingham’s Linked Cache Invalidation Draft http://tools.ietf.org/html/draft-nottingham-linked-cache-inv-03  
  • 38. Relying on these Caching Behaviors in Practice •  Compliance to HTTP 1.1 •  Interpretation of HTTP 1.1 •  Implementation variance •  Intermediaries
  • 39. 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.
  • 40. What’s Next? HTTP 2.0 http://tools.ietf.org/wg/httpbis/charters