SlideShare a Scribd company logo
1 of 20
Download to read offline
Using HTTP Link: Header for
Gateway Cache Invalidation

  Mike Kelly <mike@mykanjo.co.uk>
  Michael Hausenblas <michael.hausenblas@deri.org>
What is a gateway cache?

"reverse proxy cache"
A layer between all clients and destination server




Objective:
Minimize demand on destination server
Not so concerned with reducing bandwith
How do they work?

They can leverage the 3 principal caching mechanisms:


• Expiration
• Validation
• Invalidation


HTTP has mechanisms for each of these
Expiration-based caching

< 200 OK
< Content-Type: text/html
< Cache-Control: public, s-maxage=600
< ....

Pros:
+ Simple
+ No contact with server until expiration

Cons:
- Inefficient
- Difficult to manage
Validation-based caching

< 200 OK
< ETag: "686897696a7c876b7e"
> GET /example
> If-None-Match: "686897696a7c876b7e"
< 304 Not Modified

Pros:
+ Reduces bandwidth
+ Ensures freshness

Cons:
- Server handling every request
- Generating 304 still costs processing and I/O
Expiration+Validation caching

< 200 OK
< ETag: "686897696a7c876b7e"
< Cache-Control: public, s-maxage=600

Pros:
+ Expiration reduces contact with server
+ Validation reduces bandwidth

Cons:
- "Worst case" inefficiency
- Still managing caching rules
Invalidation-based caching

             - Responses fresh until invalidated

             (by non-safe requests)

             In HTTP:

               PUT
               POST
               PATCH
               DELETE
               (PURGE?)
How is this possible?


Product of adhering to constraints of REST, particularly:


  Uniform Interface
    + Self-descriptive messages


Intermediaries can make assertions about client-server
interactions.
Invalidation-based caching

Pros:
+ Caches have self-control
+ "Best case" efficiency
+ Ensured freshness*


Cons:
- Only reliable for gateway caches
- Impractical*




* (sort of)
Cache invalidation in practice

Two main problems for cache invalidation arise from
pragmatism and trade-offs in resource granularity and
identification:


• The "Composite Problem"

• The "Split-resource Problem"
Composite Problem

Perfect World:
<collection>
   <item rel="item" href="/items/123" />
   <item rel="item" href="/items/asdf" />
   <item rel="item" href="/items/foobar" />
</collection>


Real World:
<collection>
   <item rel="item" href="/items/123">
      <title>Item 123</title>
      <content>Content for item 123 - an example of embedded state</content>
   </item>
   <item rel="item" href="/items/asdf">
      <title>Item asdf</title>
      <content>This state is also embedded</content>
   </item>
   <item rel="item" href="/items/foobar">
      <title>FooBar</title>
      <content>Yet more embedded state!! :(</content>
   </item>
</collection>
Composite Problem

What effect would the following interaction have on the
composite collection it belongs to?




> PUT /composite-collection/item123
< 200 OK
The Split-resource Problem

Given /document resource with representations:

/document.html
/document.xml
/document.json


When a client does this:

PUT /document


Then invalidation of each representation is invisible to
intermediaries
What's the Problem?
.. The Solution

Beef up the uniform interface:

Express these common types of resource dependency as
control data using Link header and standard link relations

This increases:

  - Self-descriptiveness of messages

  - Visibility


"Link Header-based Invalidation of Caches" (LHIC)
LHIC-I

Express dependency in response to an invalidating request

> PUT /composite-collection/item123

< 200 OK
< Link: </composite-collection>;
< rel="http://example.org/rels/dependant"
LHIC-II

Express dependencies in initial cacheable responses
> GET /document.html
< 200 OK
< Link: </document>;
< rel="http://example.org/rels/dependsOn"

> GET /document.xml
< 200 OK
< Link: </document>;
< rel="http://example.org/rels/dependsOn"

> GET /document.json
< 200 OK
< Link: </document>;
< rel="http://example.org/rels/dependsOn"

> PUT /document
< 200 OK
Comparison

LHIC-I
+ More dynamic control of invalidation

- DoS risk
- Invalidation does not cascade

LHIC-II
+ No DoS risk
+ Cascading invalidation

- Complexity
Conclusion

LHIC injects lost visibility. Resulting mechanism:

+ Very efficient
+ Ensures freshness
+ Easily managed
+ Leverages existing specs

- Only for gateway caching
   + Combine Invalidation (gateway) & Validation (client)
Considerations

Resource state altered outside of uniform interface
- Don't do that
- Reintroduce expiration and validation

Peering
- Further research

Size limits for HTTP headers

More Related Content

What's hot

Database component in mule demo
Database component in mule demoDatabase component in mule demo
Database component in mule demoSudha Ch
 
Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4PawanMM
 
Session 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsSession 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsPawanMM
 
Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6PawanMM
 
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsSession 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsPawanMM
 
Customizing Share Point The Supported Wa
Customizing Share Point The Supported WaCustomizing Share Point The Supported Wa
Customizing Share Point The Supported Waguestd9aa5
 
getting started with varnish
getting started with varnishgetting started with varnish
getting started with varnishVarnish Software
 
Peer Cache for Configuration Manager clients
Peer Cache for Configuration Manager clientsPeer Cache for Configuration Manager clients
Peer Cache for Configuration Manager clientsKarthick Jokirathinam
 
Session 33 - Session Management using other Techniques
Session 33 - Session Management using other TechniquesSession 33 - Session Management using other Techniques
Session 33 - Session Management using other TechniquesPawanMM
 
Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)PawanMM
 
Ajax Frameworks in the J(2)EE Environment
Ajax Frameworks in the J(2)EE EnvironmentAjax Frameworks in the J(2)EE Environment
Ajax Frameworks in the J(2)EE Environmentstarchaser
 
Caching and Its Main Types
Caching and Its Main TypesCaching and Its Main Types
Caching and Its Main TypesHTS Hosting
 
Cloud Hosting Services
Cloud Hosting ServicesCloud Hosting Services
Cloud Hosting ServicesHTS Hosting
 

What's hot (17)

Database component in mule demo
Database component in mule demoDatabase component in mule demo
Database component in mule demo
 
Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4Session 28 - Servlets - Part 4
Session 28 - Servlets - Part 4
 
Ch. x web performance
Ch. x web performanceCh. x web performance
Ch. x web performance
 
Session 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design PatternsSession 34 - JDBC Best Practices, Introduction to Design Patterns
Session 34 - JDBC Best Practices, Introduction to Design Patterns
 
Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6Session 30 - Servlets - Part 6
Session 30 - Servlets - Part 6
 
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web AppsSession 31 - Session Management, Best Practices, Design Patterns in Web Apps
Session 31 - Session Management, Best Practices, Design Patterns in Web Apps
 
Customizing Share Point The Supported Wa
Customizing Share Point The Supported WaCustomizing Share Point The Supported Wa
Customizing Share Point The Supported Wa
 
getting started with varnish
getting started with varnishgetting started with varnish
getting started with varnish
 
Peer Cache for Configuration Manager clients
Peer Cache for Configuration Manager clientsPeer Cache for Configuration Manager clients
Peer Cache for Configuration Manager clients
 
Session 33 - Session Management using other Techniques
Session 33 - Session Management using other TechniquesSession 33 - Session Management using other Techniques
Session 33 - Session Management using other Techniques
 
Mule with stored procedure
Mule with stored procedureMule with stored procedure
Mule with stored procedure
 
SOAP vs REST
SOAP vs RESTSOAP vs REST
SOAP vs REST
 
Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)Session 37 - JSP - Part 2 (final)
Session 37 - JSP - Part 2 (final)
 
Ajax Frameworks in the J(2)EE Environment
Ajax Frameworks in the J(2)EE EnvironmentAjax Frameworks in the J(2)EE Environment
Ajax Frameworks in the J(2)EE Environment
 
Caching and Its Main Types
Caching and Its Main TypesCaching and Its Main Types
Caching and Its Main Types
 
ASP.NET WEB API
ASP.NET WEB APIASP.NET WEB API
ASP.NET WEB API
 
Cloud Hosting Services
Cloud Hosting ServicesCloud Hosting Services
Cloud Hosting Services
 

Similar to Link Header-based Invalidation of Caches

distributing over the web
distributing over the webdistributing over the web
distributing over the webNicola Baldi
 
Our application got popular and now it breaks
Our application got popular and now it breaksOur application got popular and now it breaks
Our application got popular and now it breaksColdFusionConference
 
Our application got popular and now it breaks
Our application got popular and now it breaksOur application got popular and now it breaks
Our application got popular and now it breaksdevObjective
 
Enough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas ZakasEnough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas ZakasKubide
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storeSunil Komarapu
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storeHasan Syed
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storeirfan1008
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storeSunil Komarapu
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storeF K
 
Caching invalidating with managed store
Caching invalidating with managed storeCaching invalidating with managed store
Caching invalidating with managed storePraneethchampion
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storeKhasim Saheb
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storeMohammed246
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storejaveed_mhd
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed storemdfkhan625
 
Caching invalidating with managed store
Caching invalidating with managed storeCaching invalidating with managed store
Caching invalidating with managed storeAbdulImrankhan7
 
Week 05 Web, App and Javascript_Brandon, S.H. Wu
Week 05 Web, App and Javascript_Brandon, S.H. WuWeek 05 Web, App and Javascript_Brandon, S.H. Wu
Week 05 Web, App and Javascript_Brandon, S.H. WuAppUniverz Org
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Sumy PHP User Grpoup
 

Similar to Link Header-based Invalidation of Caches (20)

distributing over the web
distributing over the webdistributing over the web
distributing over the web
 
Doing REST Right
Doing REST RightDoing REST Right
Doing REST Right
 
Our application got popular and now it breaks
Our application got popular and now it breaksOur application got popular and now it breaks
Our application got popular and now it breaks
 
Our application got popular and now it breaks
Our application got popular and now it breaksOur application got popular and now it breaks
Our application got popular and now it breaks
 
Http2 kotlin
Http2   kotlinHttp2   kotlin
Http2 kotlin
 
Enough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas ZakasEnough with the javas cript already! de Nicholas Zakas
Enough with the javas cript already! de Nicholas Zakas
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Caching invalidating with managed store
Caching invalidating with managed storeCaching invalidating with managed store
Caching invalidating with managed store
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Caching and invalidating with managed store
Caching and invalidating with managed storeCaching and invalidating with managed store
Caching and invalidating with managed store
 
Caching invalidating with managed store
Caching invalidating with managed storeCaching invalidating with managed store
Caching invalidating with managed store
 
Week 05 Web, App and Javascript_Brandon, S.H. Wu
Week 05 Web, App and Javascript_Brandon, S.H. WuWeek 05 Web, App and Javascript_Brandon, S.H. Wu
Week 05 Web, App and Javascript_Brandon, S.H. Wu
 
Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2Service approach for development Rest API in Symfony2
Service approach for development Rest API in Symfony2
 
AEM - Client Libraries
AEM - Client LibrariesAEM - Client Libraries
AEM - Client Libraries
 

Recently uploaded

CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Link Header-based Invalidation of Caches

  • 1. Using HTTP Link: Header for Gateway Cache Invalidation Mike Kelly <mike@mykanjo.co.uk> Michael Hausenblas <michael.hausenblas@deri.org>
  • 2. What is a gateway cache? "reverse proxy cache" A layer between all clients and destination server Objective: Minimize demand on destination server Not so concerned with reducing bandwith
  • 3. How do they work? They can leverage the 3 principal caching mechanisms: • Expiration • Validation • Invalidation HTTP has mechanisms for each of these
  • 4. Expiration-based caching < 200 OK < Content-Type: text/html < Cache-Control: public, s-maxage=600 < .... Pros: + Simple + No contact with server until expiration Cons: - Inefficient - Difficult to manage
  • 5. Validation-based caching < 200 OK < ETag: "686897696a7c876b7e" > GET /example > If-None-Match: "686897696a7c876b7e" < 304 Not Modified Pros: + Reduces bandwidth + Ensures freshness Cons: - Server handling every request - Generating 304 still costs processing and I/O
  • 6. Expiration+Validation caching < 200 OK < ETag: "686897696a7c876b7e" < Cache-Control: public, s-maxage=600 Pros: + Expiration reduces contact with server + Validation reduces bandwidth Cons: - "Worst case" inefficiency - Still managing caching rules
  • 7. Invalidation-based caching - Responses fresh until invalidated (by non-safe requests) In HTTP: PUT POST PATCH DELETE (PURGE?)
  • 8. How is this possible? Product of adhering to constraints of REST, particularly: Uniform Interface + Self-descriptive messages Intermediaries can make assertions about client-server interactions.
  • 9. Invalidation-based caching Pros: + Caches have self-control + "Best case" efficiency + Ensured freshness* Cons: - Only reliable for gateway caches - Impractical* * (sort of)
  • 10. Cache invalidation in practice Two main problems for cache invalidation arise from pragmatism and trade-offs in resource granularity and identification: • The "Composite Problem" • The "Split-resource Problem"
  • 11. Composite Problem Perfect World: <collection> <item rel="item" href="/items/123" /> <item rel="item" href="/items/asdf" /> <item rel="item" href="/items/foobar" /> </collection> Real World: <collection> <item rel="item" href="/items/123"> <title>Item 123</title> <content>Content for item 123 - an example of embedded state</content> </item> <item rel="item" href="/items/asdf"> <title>Item asdf</title> <content>This state is also embedded</content> </item> <item rel="item" href="/items/foobar"> <title>FooBar</title> <content>Yet more embedded state!! :(</content> </item> </collection>
  • 12. Composite Problem What effect would the following interaction have on the composite collection it belongs to? > PUT /composite-collection/item123 < 200 OK
  • 13. The Split-resource Problem Given /document resource with representations: /document.html /document.xml /document.json When a client does this: PUT /document Then invalidation of each representation is invisible to intermediaries
  • 15. .. The Solution Beef up the uniform interface: Express these common types of resource dependency as control data using Link header and standard link relations This increases: - Self-descriptiveness of messages - Visibility "Link Header-based Invalidation of Caches" (LHIC)
  • 16. LHIC-I Express dependency in response to an invalidating request > PUT /composite-collection/item123 < 200 OK < Link: </composite-collection>; < rel="http://example.org/rels/dependant"
  • 17. LHIC-II Express dependencies in initial cacheable responses > GET /document.html < 200 OK < Link: </document>; < rel="http://example.org/rels/dependsOn" > GET /document.xml < 200 OK < Link: </document>; < rel="http://example.org/rels/dependsOn" > GET /document.json < 200 OK < Link: </document>; < rel="http://example.org/rels/dependsOn" > PUT /document < 200 OK
  • 18. Comparison LHIC-I + More dynamic control of invalidation - DoS risk - Invalidation does not cascade LHIC-II + No DoS risk + Cascading invalidation - Complexity
  • 19. Conclusion LHIC injects lost visibility. Resulting mechanism: + Very efficient + Ensures freshness + Easily managed + Leverages existing specs - Only for gateway caching + Combine Invalidation (gateway) & Validation (client)
  • 20. Considerations Resource state altered outside of uniform interface - Don't do that - Reintroduce expiration and validation Peering - Further research Size limits for HTTP headers