From ef52d56d2ad353ccca987c0a81699b284895117f Mon Sep 17 00:00:00 2001 From: Joshua Johnson Date: Mon, 9 Mar 2026 14:51:11 -0500 Subject: [PATCH 1/3] Add more detail around caching directives --- docs/developers/applications/caching.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/developers/applications/caching.md b/docs/developers/applications/caching.md index 27e6f4e2..d4ed7120 100644 --- a/docs/developers/applications/caching.md +++ b/docs/developers/applications/caching.md @@ -302,6 +302,31 @@ Cache-Control: only-if-cached, no-store You may also use the `stale-if-error` to indicate if it is acceptable to return a stale cached resource when the data source returns an error (network connection error, 500, 502, 503, or 504). The `must-revalidate` directive can indicate a stale cached resource can not be returned, even when the data source has an error (by default a stale cached resource is returned when there is a network connection error). +### Context Caching Directives + +You can also specify caching directives within the context object of a CRUD operation call to a table resource. + +For example, to set the expiration time for a specific record when putting it: + +```javascript +await Post.put(postData, { expiresAt: 3600 }); +``` + +Or to disable caching on a get opperation: + +```javascript +await Post.get(primaryKey, { noCache: true, noCacheStore: true }); +``` + +| Cache-Control Header Directive | Context Directive Equivalent | Definition | +| ------------------------------ | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `max-age` | `expiresAt` | Specifies the time in seconds at which the record is scheduled to expire. | +| `no-store` | `noCacheStore` | Prevents the resource from being cached or stored. | +| `no-cache` | `noCache` | Forces revalidation with the origin server before using cached data. | +| `only-if-cached` | `onlyIfCached` | Returns the resource only if it is already cached, otherwise fails with 504 response. | +| `must-revalidate` | `mustRevalidate` | Once a resource becomes stale (i.e. past its max-age), the client must contact the origin server to revalidate before using it. It cannot serve the stale copy even as a fallback | +| `stale-if-error` | `staleIfError` | Allows serving stale resources when the origin server encounters an error. | + ## Caching Flow It may be helpful to understand the flow of a cache request. When a request is made to a caching table: From 916a5411c54f349c724167383caf88faffe2b78b Mon Sep 17 00:00:00 2001 From: Joshua Johnson Date: Mon, 9 Mar 2026 15:05:04 -0500 Subject: [PATCH 2/3] Update docs/developers/applications/caching.md Co-authored-by: Chris Barber --- docs/developers/applications/caching.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developers/applications/caching.md b/docs/developers/applications/caching.md index d4ed7120..95564524 100644 --- a/docs/developers/applications/caching.md +++ b/docs/developers/applications/caching.md @@ -312,7 +312,7 @@ For example, to set the expiration time for a specific record when putting it: await Post.put(postData, { expiresAt: 3600 }); ``` -Or to disable caching on a get opperation: +Or to disable caching on a get operation: ```javascript await Post.get(primaryKey, { noCache: true, noCacheStore: true }); From bceb460fd62fdddce1c5aec306c888dee57c2336 Mon Sep 17 00:00:00 2001 From: Joshua Johnson Date: Mon, 9 Mar 2026 15:05:17 -0500 Subject: [PATCH 3/3] Update docs/developers/applications/caching.md Co-authored-by: Chris Barber --- docs/developers/applications/caching.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developers/applications/caching.md b/docs/developers/applications/caching.md index 95564524..fd0f1c06 100644 --- a/docs/developers/applications/caching.md +++ b/docs/developers/applications/caching.md @@ -324,7 +324,7 @@ await Post.get(primaryKey, { noCache: true, noCacheStore: true }); | `no-store` | `noCacheStore` | Prevents the resource from being cached or stored. | | `no-cache` | `noCache` | Forces revalidation with the origin server before using cached data. | | `only-if-cached` | `onlyIfCached` | Returns the resource only if it is already cached, otherwise fails with 504 response. | -| `must-revalidate` | `mustRevalidate` | Once a resource becomes stale (i.e. past its max-age), the client must contact the origin server to revalidate before using it. It cannot serve the stale copy even as a fallback | +| `must-revalidate` | `mustRevalidate` | Once a resource becomes stale (i.e. past its max-age), the client must contact the origin server to revalidate before using it. It cannot serve the stale copy even as a fallback. | | `stale-if-error` | `staleIfError` | Allows serving stale resources when the origin server encounters an error. | ## Caching Flow