Cache Invalidation Test

Test the tag-to-path mapping and CDN cache clearing flow.

1. Tag-to-Path Mapping

Shows which WordPress surrogate keys are mapped to which page paths. This mapping is built by the cache handler when pages are rendered.

2. Check Response Headers

Fetch a page and inspect cache-related headers. Look for age (CDN cache age) and x-nextjs-cache (origin cache status).

3. Trigger Revalidation

Simulates a WordPress webhook. Calls revalidateTag() for each surrogate key, which invalidates the origin cache and triggers CDN path clearing.

Test Flow

  1. Visit /blogs to populate the cache (note the "Cached at" timestamp)
  2. Click "Load Tag Mapping" above to see the tag-to-path associations
  3. Click "Check /blogs" to see the current response headers (look for age header from CDN)
  4. Enter the WEBHOOK_SECRET and click "Revalidate Tags" with post-list
  5. Click "Check /blogs" again — the age header should be 0 or missing (CDN cache was cleared)
  6. Visit /blogs again — the "Cached at" timestamp should be updated (fresh render)

Using curl from terminal

# Check CDN cache headers before revalidation
curl -sI https://YOUR-SITE.pantheonsite.io/blogs | grep -iE 'age|cache-control|x-nextjs'

# Trigger revalidation
curl -X POST https://YOUR-SITE.pantheonsite.io/api/revalidate \
  -H "Content-Type: application/json" \
  -H "X-Webhook-Secret: pantheon-test-2027" \
  -d '{"surrogate_keys": ["post-list"]}'

# Check headers again — age should be reset
curl -sI https://YOUR-SITE.pantheonsite.io/blogs | grep -iE 'age|cache-control|x-nextjs'

# Check tag mapping
curl -s https://YOUR-SITE.pantheonsite.io/api/tag-mapping | python3 -m json.tool