From 899d82d28b7725e2fe6b7aafd5f18b1fe54bf417 Mon Sep 17 00:00:00 2001 From: miyamo2 Date: Mon, 20 Jan 2025 05:47:07 +0900 Subject: [PATCH] documentation --- docs/middleware/cache.md | 25 +++++++++++++++++++++++++ docs/whats_new.md | 3 ++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/middleware/cache.md b/docs/middleware/cache.md index 0723c615dc..9d0d21af52 100644 --- a/docs/middleware/cache.md +++ b/docs/middleware/cache.md @@ -10,6 +10,31 @@ Request Directives
`Cache-Control: no-cache` will return the up-to-date response but still caches it. You will always get a `miss` cache status.
`Cache-Control: no-store` will refrain from caching. You will always get the up-to-date response. +Cacheable Status Codes
+ +This middleware caches responses with the following status codes according to RFC7231: + +- `200: OK` +- `203: Non-Authoritative Information` +- `204: No Content` +- `206: Partial Content` +- `300: Multiple Choices` +- `301: Moved Permanently` +- `404: Not Found` +- `405: Method Not Allowed` +- `410: Gone` +- `414: URI Too Long` +- `501: Not Implemented` + +Additionally, `418: I'm a teapot` is not originally cacheable but is cached by this middleware. +If the status code is other than these, you will always get an `unreachable` cache status. + +For more information about cacheable status codes or RFC7231, please refer to the following resources: + +- [Cacheable - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Glossary/Cacheable) + +- [RFC7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content](https://datatracker.ietf.org/doc/html/rfc7231) + ## Signatures ```go diff --git a/docs/whats_new.md b/docs/whats_new.md index 81339d6a48..bb9870ddb6 100644 --- a/docs/whats_new.md +++ b/docs/whats_new.md @@ -733,7 +733,8 @@ The adaptor middleware has been significantly optimized for performance and effi ### Cache -We are excited to introduce a new option in our caching middleware: Cache Invalidator. This feature provides greater control over cache management, allowing you to define a custom conditions for invalidating cache entries. +We are excited to introduce a new option in our caching middleware: Cache Invalidator. This feature provides greater control over cache management, allowing you to define a custom conditions for invalidating cache entries. +Additionally, the caching middleware has been optimized to avoid caching non-cacheable status codes, as defined by the [HTTP standards](https://datatracker.ietf.org/doc/html/rfc7231#section-6.1). This improvement enhances cache accuracy and reduces unnecessary cache storage usage. ### CORS