Skip to content

TheBigRoomXXL/httpcache

Repository files navigation

HTTPCache

With httpcache immediately add support for HTTP caching semantic to you golang HTTP client.

Package pkg.lovergne.dev/httpcache/core provides an http.RoundTripper implementation that works as a mostly RFC 9111 compliant cache for HTTP responses.

It is only suitable for use as a 'private' cache (i.e. for a web-browser or an API-client and not for a shared proxy).

Acknowledgement

This project is a revival of the awesome library httpcache by gregjones which implemented support for most RFC 7234 directive. This library is really well written and quite simple in it's architecture. Most of the core of this package is still taken from that library and we simply update it where needed.

HTTP Cache Support Matrix

Here you can find in details which part of RFC9111 and related specifications are supported. Currently the biggest "gap" in support for public (aka shared) cache but it's upport is on the the roadmap.

Specification links point to precise section in the specification, not just the specification itself.

Cache-Control — Request Directives

Directive Supported Specification
max-age 🟢 rfc9111
max-stale 🟢 rfc9111
min-fresh 🟢 rfc9111
no-cache 🟢 rfc9111
no-store 🟢 rfc9111
no-transform 🟢 rfc9111
only-if-cached 🟢 rfc9111

Cache-Control — Response Directives

Directive Supported Specification
max-age 🟢 rfc9111
s-maxage 🔴 rfc9111
no-cache 🟢 rfc9111
no-store 🟢 rfc9111
no-transform 🟢 rfc9111
must-revalidate 🔴 rfc9111
proxy-revalidate 🔴 rfc9111
must-understand 🔴 rfc9111
private 🔴 rfc9111
public 🔴 rfc9111
immutable 🔴 rfc8246
stale-while-revalidate 🔴 rfc5861
stale-if-error 🟢 rfc5861

ETag Support

Directive Supported Specification
ETag strong 🟢 rfc9110, rfc9111
ETag weak (W/) 🔴 rfc9110, rfc9111
If-None-Match 🟢 rfc9110, rfc9111

Other Headers

Directive Supported Specification
If-Modified-Since 🟢 rfc9110, rfc9111
Expires 🟢 rfc9111
Range 🟢 rfc9110, rfc9111
Pragma 🔴 rfc9111
Clear-Site-Data 🔴 w3
Cache-Status 🔴 rfc9211

License

About

Implementent HTTP Caching (RFC9111) on top of golang http.RoundTripper

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 15