Technical & Integration Support
Webhooks and Cache Clearing (Next.js & Frappe)
Understanding On-Demand ISR
Marketora avoids the sluggish rebuild cycles of traditional static site generators by pairing Next.js On-Demand ISR (Incremental Static Regeneration) with Frappe Document Event Hooks.
How the Revalidation Loop Operates
- Frappe doc_events: Whenever a content document (e.g.,
MK Help ArticleorMK Blog Post) is created, updated, or trashed, Frappe triggersmarketora_cms.revalidate.on_content_change. - Tag Resolution: The CMS calls
doc.revalidation_tags()to gather the precise cache tags affected. For an article with slugwelcome-to-marketora, the tags includehelp-article:welcome-to-marketoraandhelp-articles. - Secure POST Webhook: Frappe sends a POST request to your Next.js application at
/api/revalidatecontaining the tags and the shared secret: - Timing-Safe Validation: Next.js verifies the secret using a timing-safe equality check, calls
revalidateTag(tag)for each tag, and confirms revalidation with HTTP 200.
{
"secret": "YOUR_REVALIDATE_SECRET",
"tags": ["help-article:welcome-to-marketora", "help-articles"]
}Debugging Cache Issues
If updates are not reflected immediately, ensure that:
- The
marketing_urlandrevalidate_secretkeys are present insite_config.jsonon your Frappe bench. - The Next.js environment has the matching
REVALIDATE_SECRETvariable set.
