Quoi de neuf dans le monde du cache HTTP

What's new in the HTTP cache world

What's new in the HTTP cache world

Sylvain Combraque

Creator of Souin HTTP cache

Træfik helper/ambassador

Cache-handler maintainer 

Open-source contributor

@Darkweak

@Darkweak_dev

Disclaimer

✊ Tech is political

💬 Ask during the conference

Join onestlatech in 🇫🇷

The chaos between the providers

HTTP/1.0

📉 low description

📉 low customization

😮‍💨 lot of own implementations

June 1999

RFC-2616

HTTP/1.1

The WWW beginnings

📚 Grammar

🕵️‍♂️ Resource identifier

🔗 URI

🔤 Content-Encoding

RFC-2616

13.x: Caching in HTTP

Caching would be useless if it did not significantly improve performance

RFC-2616

13.x: Caching in HTTP

If a stored response is not "fresh enough" [...] the cache MAY still return the response with the appropriate Warning header

RFC-2616

Cache-Control commons

🙅‍♂️ no-cache

✋ no-store

⏱️ max-age

🫡 no-transform

RFC-2616

Cache-Control HTTP request

⏱️ max-stale

🤷‍♂️ min-fresh

💁‍♂️ only-if-cached

RFC-2616

🔓 public

🔐 private

🤙 must-revalidate

🤙 proxy-revalidate

⏱️ s-maxage

Cache-Control HTTP response

RFC-2616

  • community="UCI"

  • only-if-my-case-match="that-should"

Cache-Control cache-extension

August 2001

ESI Language

ESI tags

ESI tags

<esi:include 
  src="http://example.com/1.html" 
  alt="http://bak.example.com/2.html" 
  onerror="continue"
/>

ESI tags

<esi:try> 
  <esi:attempt>
    <esi:comment text="Include an ad"/> 
    <esi:include src="http://www.example.com/ad1.html"/> 
  </esi:attempt>
  <esi:except> 
    <esi:comment text="Just write some HTML instead"/> 
    <a href=www.akamai.com>www.example.com</a>
  </esi:except> 
</esi:try>

ESI tags

<esi:vars>
  <img 
    src="http://www.example.com/$(HTTP_COOKIE{type})/hello.gif"
    alt="$(HTTP_COOKIE{logo_name})"
  />
</esi:vars>

ESI tags

<img 
  src="http://www.example.com/human/hello.gif"
  alt="My human GIF"
/>

ESI tags

ESI tags

June 2014

RFC-7234

HTTP/1.1 Caching

RFC-7234

HTTP response header Age

Age: 10
Age: -5

RFC-7234

Invalidation

RFC-7234

Cache-Control HTTP response

🤘 stale-while-revalidate

2015

HTTP/2

🏎💨

HTTP/2

HTTP/2

HTTP/2

June 2022

RFC-9211 & RFC-9213

The Cache-Status & Target-Cache-Control
HTTP response Header fields

RFC-9211

Cache-Status directives

💥 hit

📩 fwd

ℹ️ fwd-status

⏱️ ttl

👌 stored

🙏 collapsed

🔑 key

🤓 detail

RFC-9211

Cache-Status directives

Cache-Status: Your-Cache-Server; hit; ttl=3; key=your-pattern
Cache-Status: Your-Cache-Server; fwd=uri-miss; fwd-status=304
Cache-Status: Your-Cache-Server; fwd=uri-miss; detail=STORAGE-UNREACHABLE

RFC-9213

Target-Cache-Control

CDN

Varnish

Caddy 

Upstream

RFC-9213

Target-Cache-Control

CDN

Varnish

Caddy 

Upstream

RFC-9213

Target-Cache-Control

CDN

Varnish

Caddy 

Upstream

Cache-Control: no-store
CDN-Cache-Control: public, max-age=120, s-maxage=120
Varnish-Cache-Control: public, max-age=360, s-maxage=360
Caddy-Cache-Control: public, max-age=3600, s-maxage=3600

RFC-9213

Target-Cache-Control

CDN

Varnish

Caddy 

Upstream

Cache-Control: no-store
CDN-Cache-Control: public, max-age=120, s-maxage=120
Varnish-Cache-Control: public, max-age=360, s-maxage=360
Caddy-Cache-Control: public, max-age=3600, s-maxage=3600

3600s

RFC-9213

Target-Cache-Control

CDN

Varnish

Caddy 

Upstream

Cache-Control: no-store
CDN-Cache-Control: public, max-age=120, s-maxage=120
Varnish-Cache-Control: public, max-age=360, s-maxage=360
Caddy-Cache-Control: public, max-age=3600, s-maxage=3600

360s

RFC-9213

Target-Cache-Control

CDN

Varnish

Caddy 

Upstream

Cache-Control: no-store
CDN-Cache-Control: public, max-age=120, s-maxage=120
Varnish-Cache-Control: public, max-age=360, s-maxage=360
Caddy-Cache-Control: public, max-age=3600, s-maxage=3600

120s

RFC-9213

Target-Cache-Control

Cache-Control: no-store
CDN-Cache-Control: public, max-age=120, s-maxage=120
Varnish-Cache-Control: public, max-age=360, s-maxage=360
Caddy-Cache-Control: public, max-age=3600, s-maxage=3600

Client

no-cache

What about the future...

Probably in June

Surrogate-keys

First group

Second group

Third group

key 1

key 3

key 564

key 90

key ABC

key 3

key 789

key 1

key 789

Surrogate-keys

So much implementation

Prepare an RFC to make it standard

Resources

Resources

https://github.com/http-tests/cache-tests

https://cache-tests.fyi

Resources

https://www.rfc-editor.org

👇That's the French paracetamol👇

Lazy to manage an HTTP cache?

Thank you for your attention

Give your feedbacks👉

Quoi de neuf dans le monde du cache HTTP

By darkweak

Quoi de neuf dans le monde du cache HTTP

  • 243