Join onestlatech in 🇫🇷
Bonjour, j'aimerai savoir de quoi parle Harry Potter
Très bien, laissez-moi quelques secondes
C'est un roman fantastique qui traite de la magie
Bonjour, j'aimerai savoir de quoi parle Harry Potter
C'est un roman fantastique qui traite de la magie
Go/ReactJS architect freelance
Polyglot dev
Cache-handler maintainer
Open-source contributor
@Darkweak
@Darkweak_dev
Head of happiness in my house
HTTP/1.1
Caching would be useless if it did not significantly improve performance
If a stored response is not "fresh enough" [...] the cache MAY still return the response with the appropriate Warning header
@mnot
Multiple RFC creator (38)
Fastly, Cloudflare, Akamai
Performances
Won't answer to your questions
When you think it's simple, RFC tells you it is not
1. Introduction
HTTP is typically used for distributed information systems, where performance can be improved by the use of response caches. This document defines aspects of HTTP/1.1 related to caching and reusing response messages. An HTTP cache is a local store of response messages and the subsystem that controls storage, retrieval, and deletion of messages in it. A cache stores cacheable responses in order to reduce the response time and network bandwidth consumption on future, equivalent requests. Any client or server MAY employ a cache, though a cache cannot be used by a server that is acting as a tunnel. A shared cache is a cache that stores responses to be reused by more than one user; shared caches are usually (but not always) deployed as a part of an intermediary. A private cache, in contrast, is dedicated to a single user; often, they are deployed as a component of a user agent. The goal of caching in HTTP/1.1 is to significantly improve performance by reusing a prior response message to satisfy a current request. A stored response is considered "fresh", as defined in Section 4.2, if the response can be reused without "validation" (checking with the origin server to see if the cached response remains valid for this request). A fresh response can therefore reduce both latency and network overhead each time it is reused. When a cached response is not fresh, it might still be reusable if it can be freshened by validation (Section 4.3) or if the origin is unavailable (Section 4.2.4).
1.1. Conformance and Error Handling
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119]. Conformance criteria and considerations regarding error handling are defined in Section 2.5 of [RFC7230].
1.2. Syntax Notation
This specification uses the Augmented Backus-Naur Form (ABNF) notation of [RFC5234] with a list extension, defined in Section 7 of [RFC7230], that allows for compact definition of comma-separated lists using a '#' operator (similar to how the '*' operator indicates Fielding, et al. Standards Track [Page 4]
RFC-7234
<esi:include
src="http://example.com/1.html"
alt="http://bak.example.com/2.html"
onerror="continue"
/><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:vars>
<img
src="http://www.example.com/$(HTTP_COOKIE{type})/hello.gif"
alt="$(HTTP_COOKIE{logo_name})"
/>
</esi:vars><img
src="http://www.example.com/human/hello.gif"
alt="My human GIF"
/>HTTP/1.1 Caching
Age: 10Age: -5The Cache-Status & Target-Cache-Control HTTP response Header fields
Cache-Status: Your-Cache-Server; hit; ttl=3; key=your-patternCache-Status: Your-Cache-Server; fwd=uri-miss; fwd-status=304Cache-Status: Your-Cache-Server; fwd=uri-miss; detail=STORAGE-UNREACHABLECDN
Varnish
Caddy
Upstream
CDN
Varnish
Caddy
Upstream
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=3600CDN
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=36003600s
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=3600360s
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=3600120s
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=3600Client
no-cache
The HTTP Cache Groups
HTTP/1.1 200 OK
Content-Type: application/javascript
Cache-Control: max-age=3600
Cache-Groups: "scripts", "another"
HTTP/1.1 200 OK
Content-Type: application/javascript
Cache-Control: max-age=3600
Cache-Groups: "/books"
HTTP/1.1 200 OK
Content-Type: application/javascript
Cache-Control: max-age=3600
Cache-Groups-Invalidation: "one", "two"
HTTP/1.1 200 OK
Content-Type: application/javascript
Cache-Control: max-age=3600
Cache-Groups-Invalidation: "/books"
/books?page=1
/books/1
/books?page=2
/books?name=L
/books/1
/users/1
/template/1
/other-resource
/books/2
/users/2
/template/2
/other-resource
/books?page=1
/books/1
/books?page=2
/books?name=L
/books/1
/users/1
/template/1
/other-resource
/books/2
/users/2
/template/2
/other-resource
The HTTP Cache Groups Invalidation API
{
"type": "uri",
"selectors": [
"https://example.com/foo/bar",
"https://example.com/foo/bar/baz"
]
"purge": false
}{
"type": "group",
"selectors": [
"https://example.com:443",
"https://www.example.com:443"
],
"groups": [
"scripts"
]
}POST /to/your/invalidation-api
https://github.com/http-tests/cache-tests
https://cache-tests.fyi
Leave a ⭐️ on Github