SlideShare a Scribd company logo
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

PPTX
Session 29 - Servlets - Part 5
PPTX
Session 26 - Servlets Part 2
PDF
Architecting Large Enterprise Java Projects
PPTX
Session 25 - Introduction to JEE, Servlets
ODP
Running ms sql stored procedures in mule
PPTX
Session 39 - Hibernate - Part 1
PDF
How Varnish & MongoDB Scale Business Insider
PPTX
Session 32 - Session Management using Cookies
Session 29 - Servlets - Part 5
Session 26 - Servlets Part 2
Architecting Large Enterprise Java Projects
Session 25 - Introduction to JEE, Servlets
Running ms sql stored procedures in mule
Session 39 - Hibernate - Part 1
How Varnish & MongoDB Scale Business Insider
Session 32 - Session Management using Cookies

What's hot (17)

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

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

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

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Spectroscopy.pptx food analysis technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Big Data Technologies - Introduction.pptx
A Presentation on Artificial Intelligence
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
20250228 LYD VKU AI Blended-Learning.pptx
The AUB Centre for AI in Media Proposal.docx
Chapter 3 Spatial Domain Image Processing.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Encapsulation theory and applications.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
cuic standard and advanced reporting.pdf
Programs and apps: productivity, graphics, security and other tools
Encapsulation_ Review paper, used for researhc scholars
Spectroscopy.pptx food analysis technology
Per capita expenditure prediction using model stacking based on satellite ima...
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

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