api-cache-invalidation

Automate Laravel and Next.js ISR cache invalidation via backend observers and revalidation.

Updated Oct 26, 2025
One-click install
npx skills add https://github.com/Hieubkav/wincellarCloneBackend --skill api-cache-invalidation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-cache-invalidation
Source: https://github.com/Hieubkav/wincellarCloneBackend/tree/main/.claude/skills/api/api-cache-invalidation
Command: npx skills add https://github.com/Hieubkav/wincellarCloneBackend --skill api-cache-invalidation

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides patterns for synchronizing backend changes with frontend caches via cache invalidation and on-demand revalidation.

Core Features & Use Cases

  • Hybrid cache strategy with time-based and on-demand revalidation
  • Backend observers incrementing cache/version counters
  • Frontend ISR integration and revalidation endpoints
  • Easy integration with Laravel and Next.js stacks

Quick Start

Wire a backend event to trigger a Next.js revalidation call and refresh cache on the frontend.

Frequently Asked Questions about api-cache-invalidation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I invalidate Next.js cache when my Laravel backend data changes?

Cache invalidation detects backend data changes and triggers Next.js on-demand revalidation by incrementing a cache version. Use Laravel observers to bump the version counter when models update, then call Next.js revalidation endpoints to refresh ISR pages automatically.

Can I use cache invalidation with Laravel and Next.js ISR?

Yes, this pattern is built specifically for Laravel and Next.js ISR setups. It combines backend observers that increment cache versions with frontend revalidation services, supporting core models like Menu, Product, Article, and Image across admin updates and data synchronization.

What's the best way to sync backend changes with frontend caches?

A hybrid cache strategy using both time-based and on-demand revalidation works best. Include the cache version in API responses, wire backend events to trigger Next.js revalidation calls, and use a 10-second fallback for automatic cache refresh.

Do I need a revalidation service to keep my Next.js cache fresh?

A revalidation service bridges backend changes to Next.js ISR by triggering on-demand refreshes. The Skill implements this pattern alongside time-based fallback, so your cache stays synchronized without manual intervention across admin updates and data-change events.

How does cache versioning work in a Laravel and Next.js stack?

Cache versioning increments a counter in your Laravel backend whenever data changes. The API includes this version in responses, and Next.js detects version changes to invalidate stale ISR pages, ensuring frontend content matches backend state.

What happens if my revalidation endpoint fails or is delayed?

A 10-second time-based fallback ensures cache refresh even if on-demand revalidation fails. This dual approach prevents indefinite stale content while prioritizing immediate invalidation for critical updates.