1. High traffic and data transfer
With cache + CDN, many users at once do not cause a big spike in microCMS data transfer.
Nitro serves most requests from cache; the CDN serves many before they even reach your server. So microCMS is only called when a cache entry is missing or revalidating.
2. Why use a Webhook?
Caching keeps transfer low but can delay when new content appears (e.g. up to 1 hour).
Webhook = “content changed in microCMS” → your app reacts (e.g. invalidate cache or rebuild) so the next request gets fresh data.
So you get both: low data transfer (cache) and fast content updates (webhook-triggered invalidation). That’s why microCMS Webhook is used.
3. What was added
- docs/CACHE_AND_WEBHOOK.md – Short explanation of cache + webhook and how they work together.
- POST /api/webhook – Webhook receiver that:
- Verifies
x-microcms-signaturewithMICROCMS_WEBHOOK_SECRET - Clears Nitro cache (list/article/featured-news) so the next request hits microCMS and returns fresh data
- Verifies
- runtimeConfig.microcms.webhookSecret – Reads from
MICROCMS_WEBHOOK_SECRET(server-only).
4. How to use it
- In microCMS: API設定 → Webhook → カスタム通知 → URL:
https://your-domain.com/api/webhook, set the same secret in “Webhookのセキュリティ保護”. - In your env: set
MICROCMS_WEBHOOK_SECRETto that secret. - When you publish/update/delete content, microCMS POSTs to
/api/webhook→ cache is cleared → new article (and list) appear on the next request without waiting for cache TTL.
So: traffic spike is still handled by cache; new articles appear quickly because of the webhook.