Repository navigation
Revalidate storefront cache on product webhook events (F4) - #4
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Admin-side product changes (create/update/delete) were only visible
after the 10-minute "use cache" TTL — deleting a product in the admin
kept it showing on the storefront even after a refresh. The backend
already publishes product.created/updated/deleted through the same
webhook pipeline as order events, so this just wires up a handler that
busts the products/product-filters/product:{slug} cache tags and the
route cache on those events (closes F4 for the product case).
Still needs a webhook endpoint configured in the admin (Settings ->
Webhooks) subscribed to these three events, pointing at this
storefront's /api/webhooks/spree.
pawelekbyra
force-pushed
the
claude/image-upload-display-diagnosis-qevpga
branch
from
July 7, 2026 12:18
3243921 to
77d1bfc
Compare
This was referenced Jul 7, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"use cache"TTL — deleting a product stayed visible even after a manual refresh.product.created/product.updated/product.deletedthrough the same webhook pipeline as order events (Spree::Producthaspublishes_lifecycle_events— no backend code change needed).handleProductChangedinsrc/lib/webhooks/handlers.ts, wired to those three event names in/api/webhooks/spree/route.ts. It busts theproducts,product-filters, andproduct:{slug}cache tags plusrevalidatePath("/", "layout")— same escape hatch already used by the manual/api/revalidateendpoint.docs/technical-debt.md(closes the F4 entry) anddocs/deployment-vercel.md(checklist + env var docs forSPREE_WEBHOOK_SECRET's expanded role).Manual step required after merge
A webhook endpoint must exist in the admin (Settings → Webhooks) pointing at this storefront's
/api/webhooks/spree, subscribed toproduct.created/product.updated/product.deleted(orproduct.*), using the same secret asSPREE_WEBHOOK_SECRETon Vercel. Without this, events are never sent and the fix has no effect.Test plan
npx tsc --noEmitcleannpx biome checkcleannpx vitest run— 91/91 passing (addedsrc/lib/webhooks/__tests__/handlers.test.ts)Generated by Claude Code