Skip to content

[Hyperdrive] Add query cache consistency guidance#31746

Draft
irvinebroque wants to merge 2 commits into
productionfrom
docs/hyperdrive-cache-read-after-write-guidance
Draft

[Hyperdrive] Add query cache consistency guidance#31746
irvinebroque wants to merge 2 commits into
productionfrom
docs/hyperdrive-cache-read-after-write-guidance

Conversation

@irvinebroque

Copy link
Copy Markdown
Contributor

Summary

  • Document that Hyperdrive does not invalidate cached read results after writes.
  • Add guidance for splitting cacheable reads from fresh reads with separate Hyperdrive configurations.
  • Add discovery points in the FAQ, troubleshooting, get started, how Hyperdrive works, and PlanetScale pages.

Validation

  • pnpm exec prettier --check on edited MDX files
  • git diff --check
  • pnpm run check:astro fails on existing generated skills/turnstile-spin TypeScript files missing ExportedHandler and Fetcher, unrelated to these docs changes.

@github-actions github-actions Bot added product:hyperdrive Hyperdrive: https://developers.cloudflare.com/hyperdrive/ size/m labels Jun 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/hyperdrive/ @elithrar, @rita3ko, @irvinebroque, @vy-ton, @ivoryibu, @thomasgauvin, @sejoker, @oxyjun, @knickish, @cloudflare/product-owners

@ask-bonk ask-bonk Bot added the documentation Documentation edits label Jun 27, 2026

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Overall: Approved with one minor suggestion. This is a well-scoped, clearly written documentation change.

What changed

  • Documents that Hyperdrive does not invalidate cached reads after writes.
  • Adds a new Read-after-write behavior section to the Query caching concept page with practical guidance on when to use caching vs. cache-disabled configurations.
  • Renames example binding from HYPERDRIVE_CACHE_DISABLED to HYPERDRIVE_FRESH for clarity.
  • Adds discovery points in FAQ, Troubleshooting, Get started, How Hyperdrive works, and PlanetScale pages.
  • Re-formats several Markdown tables in troubleshooting.mdx for readability.
  • Fixes US/UK spelling inconsistency (behaviour -> behavior).

Validation

  • prettier --check passes on all 6 edited files.
  • git diff --check passes.
  • pnpm run check passes with 0 errors.

Minor suggestion

In troubleshooting.mdx, the "TLS handshake failed" row contains a pre-existing typo: "the expected the correct" should be "the expected correct" or "the correct". Since this PR is already reformatting that table, it would be a good time to fix the duplicate word.

@ask-bonk

ask-bonk Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Reviewed and approved PR #31746.

Labels applied: documentation (in addition to existing product:hyperdrive and size/m).

Summary of changes

This PR adds clear guidance that Hyperdrive does not invalidate cached read results after writes, and shows users how to handle read-after-write consistency by using separate cache-disabled Hyperdrive configurations. Key changes across 6 files:

  • query-caching.mdx: New "Read-after-write behavior" section with actionable caching strategies; renames example binding from HYPERDRIVE_CACHE_DISABLED to HYPERDRIVE_FRESH for clarity; updates the caution note about SQL comments not being a cache-control API.
  • faq.mdx: New "Caching" FAQ section answering two common questions.
  • troubleshooting.mdx: New "Stale reads after writes" subsection; significant table formatting improvements.
  • how-hyperdrive-works.mdx, get-started.mdx, planetscale.mdx: Added cross-references to the new caching guidance.

Validation

  • pnpm exec prettier --check
  • git diff --check
  • pnpm run check ✅ (0 errors)

Flagged issue

I noted one pre-existing typo in troubleshooting.mdx in the "TLS handshake failed" table row: "the expected the correct" should be "the correct" or "the expected correct". Since this PR is already reformatting that table, it's a good opportunity to fix the duplicate word inline.

github run

@irvinebroque irvinebroque left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes make sense, but wonder if we are repeating the same thing in slightly different ways across many places. See comemnts

Comment thread src/content/docs/hyperdrive/concepts/how-hyperdrive-works.mdx Outdated
Comment thread src/content/docs/hyperdrive/concepts/query-caching.mdx Outdated
Comment thread src/content/docs/hyperdrive/concepts/query-caching.mdx Outdated
Comment thread src/content/docs/hyperdrive/concepts/query-caching.mdx Outdated
Comment thread src/content/docs/hyperdrive/observability/troubleshooting.mdx Outdated
Hyperdrive uses text-based pattern matching to detect some uncacheable functions in your queries. This can include function names inside SQL comments.

For example, the following query would **not** be cached because `NOW()` appears in the comment:
Do not rely on comments such as `-- NOW()` or `-- RAND()` to bypass query caching. Hyperdrive does not document SQL comments as a cache-control API, and parser behavior can differ between database engines. Use a cache-disabled Hyperdrive configuration when you need a guaranteed fresh read.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refs guidance I got from Pranoy — @ivoryibu worth talking to him to make sure we've got this right

@github-actions

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation edits product:hyperdrive Hyperdrive: https://developers.cloudflare.com/hyperdrive/ size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants