Skip to main content

Cache Invalidation (Domain Mapping)

Introduction

NextJS relies on content and menu items served by Drupal. A data synchronization strategy is implemented to ensure that data updates on Drupal side propagate to NextJS through a seamless cache invalidation strategy. This is a summary of how such transactions are mapped between Drupal and Vercel (NextJS hosting).

Environment Mapping

EnvironmentActionResults InWhich Updates
DEVSave any Story, Card, Person, etc. (content) (i.e. story ID 1234, alias /test)Invalidation request being sent to https://www-dev01.charles-schwab.vercel.app/api/revalidate/?tags=story_published_en,node:1234&source=prospectsitecollectionApp hosted at https://www-dev.schwab.com/learn/story/test
Save redirectInvalidation request being sent to https://www-dev01.charles-schwab.vercel.app/api/revalidate/?type=redirect&source=prospectsitecollectionRedirect list for https://www-schwab-dev.vercel.app
Save menu linkInvalidation request being sent to https://meganav-mfe-dev01.charles-schwab.vercel.app/api/output/json?source=prospectsitecollection&relativePath=false&revalidate=trueBoth https://www-dev.schwab.com
Save smart bannerSAME AS SAVING CONTENT
TRAINSave any Story, Card, Person, etc. (content) (i.e. story ID 1234, alias /test)Invalidation request being sent to https://www-dev01.charles-schwab.vercel.app/api/revalidate/?tags=story_published_en,node:1234&source=prospectsitecollectionApp hosted at https://www-train.schwab.com/learn/story/test
Save redirectInvalidation request being sent to https://www-dev01.charles-schwab.vercel.app/api/revalidate/?type=redirect&source=prospectsitecollectionRedirect list for https://www-schwab-train.vercel.app
Save menu linkInvalidation request being sent to https://meganav-mfe-dev01.charles-schwab.vercel.app/api/output/json?source=prospectsitecollection&relativePath=false&revalidate=trueboth https://www-train.schwab.com
Save smart bannerSAME AS SAVING CONTENT
UATSave any Story, Card, Person, etc. (content) (i.e. story ID 1234, alias /test)Invalidation request being sent to https://www-sit02.charles-schwab.vercel.app/api/revalidate/?tags=story_published_en,node:1234&source=prospectsitecollectionApp hosted at https://www-uat.schwab.com/learn/story/test
Save redirectInvalidation request being sent to https://www-sit02.charles-schwab.vercel.app/api/revalidate/?type=redirect&source=prospectsitecollectionRedirect list for https://www-schwab-uat.vercel.app
Save menu linkInvalidation request being sent to https://meganav-mfe-sit02.charles-schwab.vercel.app/api/output/json?source=prospectsitecollection&relativePath=false&revalidate=trueBoth https://www-uat.schwab.com
Save smart bannerSAME AS SAVING CONTENT
PRODSave any Story, Card, Person, etc. (content) (i.e. story ID 1234, alias /test)Invalidation request being sent to https://www.charles-schwab.vercel.app/api/revalidate/?tags=story_published_en,node:1234&source=prospectsitecollectionApp hosted at https://www.schwab.com/learn/story/test
Save redirectInvalidation request being sent to https://www-schwab.vercel.app/api/revalidate/?type=redirect&source=prospectsitecollectionRedirect list for https://www-schwab.vercel.app
Save menu linkInvalidation request being sent to https://meganav-mfe.charles-schwab.vercel.app/api/output/json?source=prospectsitecollection&relativePath=false&revalidate=trueBoth https://www.schwab.com
Save smart bannerSAME AS SAVING CONTENT
TESTN/A
PVSN/A

Cache Invalidation Strategy

Content Updates

When content is saved in Drupal CMS:

  1. Drupal triggers a revalidation request to the appropriate Vercel environment
  2. The request includes specific tags (e.g., story_published_en, node:1234)
  3. Next.js invalidates cached pages that match these tags
  4. Fresh content is fetched on the next request

When menu items are updated:

  1. Drupal sends invalidation request to the meganav micro-frontend
  2. Both the main site and navigation components are updated
  3. Changes propagate across all affected pages

Redirect Updates

When redirects are modified:

  1. Drupal triggers revalidation of the redirect configuration
  2. Next.js updates its internal redirect mapping
  3. New redirect rules take effect immediately

Key Benefits

  1. Real-time Updates: Content changes in Drupal appear on the live site without manual intervention
  2. Performance: Only affected pages are invalidated, maintaining cache performance for unaffected content
  3. Reliability: Automated process reduces risk of content inconsistencies
  4. Environment Parity: Same invalidation strategy works across all environments

Monitoring & Troubleshooting

  • Monitor invalidation requests in Vercel deployment logs
  • Check Drupal logs for failed webhook calls
  • Verify cache tags are properly set on Next.js pages
  • Test invalidation manually using the revalidate API endpoints