Spache

Cache invalidation webhooks

Tell Spache when your origin has changed so visitors do not wait for the normal cache lifetime or dependency check.

Generate a webhook URL

  1. Open a site and go to Settings → Webhooks.
  2. Click Generate webhook URL.
  3. Copy the URL into the secret store used by your deployment system.
  4. If the URL is exposed, revoke it and generate a replacement.

Invalidate the whole site

Use this after a successful deployment. It invalidates all cached routes for the site.

curl --fail --retry 3 \
  -X POST "$SPACHE_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  --data '{"mode":"site","source":"deployment"}'

Invalidate one route

Use this when a CMS or content update affects only one route.

curl --fail --retry 3 \
  -X POST "$SPACHE_WEBHOOK_URL" \
  -H 'Content-Type: application/json' \
  --data '{"mode":"route","path":"/products/example","source":"cms"}'

GitHub Actions

Add the generated URL as a repository or environment secret named SPACHE_WEBHOOK_URL. Call it after the deployment step succeeds.

- name: Invalidate Spache cache
  if: success()
  env:
    SPACHE_WEBHOOK_URL: ${{ secrets.SPACHE_WEBHOOK_URL }}
  run: |
    curl --fail --retry 3 \
      -X POST "$SPACHE_WEBHOOK_URL" \
      -H 'Content-Type: application/json' \
      --data '{"mode":"site","source":"github","commit":"'"$GITHUB_SHA"'"}'

Render

Create a Render workspace webhook and point it at the generated Spache URL. Subscribe to deploy_ended events and configure the webhook to send only successful deployments, if that option is available in your Render plan. If your Render webhook also sends failed or cancelled deployments, do not invalidate for those events.

The generated Spache URL is the authentication credential for this endpoint. Keep it in Render’s secret configuration where possible, and do not paste it into site content or client-side code.

Delivery behavior

Webhook delivery is safe to retry. Site invalidation bumps the site cache version; route invalidation creates a new version for that route. The response confirms that the invalidation was accepted, not that a new render has completed.