Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
miyamo2 committed Jan 19, 2025
1 parent 04eb05e commit 899d82d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions docs/middleware/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,31 @@ Request Directives<br />
`Cache-Control: no-cache` will return the up-to-date response but still caches it. You will always get a `miss` cache status.<br />
`Cache-Control: no-store` will refrain from caching. You will always get the up-to-date response.

Cacheable Status Codes<br />

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.

Check failure on line 30 in docs/middleware/cache.md

View workflow job for this annotation

GitHub Actions / markdownlint

Trailing spaces

docs/middleware/cache.md:30:91 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 2] https://github.com/DavidAnson/markdownlint/blob/v0.37.4/doc/md009.md

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
Expand Down
3 changes: 2 additions & 1 deletion docs/whats_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 899d82d

Please sign in to comment.