Skip to content

feat(api): add tag-based revalidation to FrontendRevalidationService #86

@joaquimscosta

Description

@joaquimscosta

Summary

The frontend now supports tag-based cache invalidation via cacheTag() (added in PR #85), but the backend FrontendRevalidationService only supports path-based revalidation ({"path": "..."}). Add a revalidateTag(tag: String) method to complete the end-to-end cache invalidation flow.

Current State

  • Frontend: /api/revalidate endpoint accepts {"tag": "gallery"} and calls revalidateTag(tag, { expire: 0 })
  • Frontend pages: Use cacheTag("directory"), cacheTag("gallery"), cacheTag(\photo:${id}`), cacheTag(`entry:${category}:${slug}`)`, etc.
  • Backend: FrontendRevalidationService.revalidatePath() only sends {"path": "/..."} — no tag support

Proposed Changes

  1. Add revalidateTag(tag: String) method to FrontendRevalidationService
  2. Send {"tag": "gallery"} body format to /api/revalidate
  3. Call revalidateTag("gallery") from gallery admin operations (promote hero, approve/reject media)
  4. Call revalidateTag("directory") from directory admin operations

Files

  • apps/api/src/main/kotlin/com/nosilha/core/shared/service/FrontendRevalidationService.kt
  • Gallery and directory admin service classes that trigger revalidation

Context

This was identified during code review of PR #85 (Phase 1 performance optimization). The tag infrastructure was scaffolded on the frontend; this issue completes the backend integration (Phase 2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions