Skip to content

Commit 7c31a3c

Browse files
Add docs from gofiber/fiber@8970f51
1 parent c09ab73 commit 7c31a3c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

docs/core/middleware/cache.md

+25
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@ Request Directives<br />
1010
`Cache-Control: no-cache` will return the up-to-date response but still caches it. You will always get a `miss` cache status.<br />
1111
`Cache-Control: no-store` will refrain from caching. You will always get the up-to-date response.
1212

13+
Cacheable Status Codes<br />
14+
15+
This middleware caches responses with the following status codes according to RFC7231:
16+
17+
- `200: OK`
18+
- `203: Non-Authoritative Information`
19+
- `204: No Content`
20+
- `206: Partial Content`
21+
- `300: Multiple Choices`
22+
- `301: Moved Permanently`
23+
- `404: Not Found`
24+
- `405: Method Not Allowed`
25+
- `410: Gone`
26+
- `414: URI Too Long`
27+
- `501: Not Implemented`
28+
29+
Additionally, `418: I'm a teapot` is not originally cacheable but is cached by this middleware.
30+
If the status code is other than these, you will always get an `unreachable` cache status.
31+
32+
For more information about cacheable status codes or RFC7231, please refer to the following resources:
33+
34+
- [Cacheable - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Glossary/Cacheable)
35+
36+
- [RFC7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content](https://datatracker.ietf.org/doc/html/rfc7231)
37+
1338
## Signatures
1439

1540
```go

docs/core/whats_new.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,8 @@ The adaptor middleware has been significantly optimized for performance and effi
764764

765765
### Cache
766766

767-
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.
767+
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.
768+
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.
768769

769770
### CORS
770771

0 commit comments

Comments
 (0)