Skip to content

Trigger GET request to page slug after publish to generate page post-invalidation (Next.js) #773

@surajair

Description

@surajair

Problem

Currently, when a page is published in the Chai Builder, the system calls the Next.js revalidation API (/api/revalidate) which invalidates the cache using revalidatePath() and revalidateTag(). However, this only marks the cache as stale—it doesn't actually regenerate the page.

To ensure the page is immediately generated and ready to serve (ISR/SSG), we should trigger a GET request to each published page's slug after the revalidation completes. This will force Next.js to regenerate the static page on the server.

Current Flow

  1. User publishes page(s) via publish button/modal
  2. PublishChangesAction executes (backend)
  3. Pages are copied to appPagesOnline table
  4. Revalidation webhook is called → /api/revalidate endpoint
  5. revalidatePath() / revalidateTag() invalidates cache
  6. ❌ Page is NOT generated until first user visit

Desired Flow

  1. User publishes page(s)
  2. PublishChangesAction executes
  3. Pages copied to appPagesOnline
  4. Revalidation webhook called
  5. Cache invalidated
  6. ✅ For each published page with a slug, trigger GET /<slug> to force generation

Acceptance Criteria

  • After publishing page(s), the Next.js app triggers GET requests to all affected slugs
  • GET requests are made AFTER cache invalidation completes
  • Only pages with valid slugs are requested (skip "THEME" or pages without slugs)
  • Errors in page generation don't block the publish flow (fail gracefully)
  • Works across all publish entry points (topbar, modal, theme publish)

Metadata

Metadata

Labels

nextjsRegarding the NextJS package

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions