Skip to content

Feature: Add cache key deletion support based on collection UID and slug, with optional key tagging #11

@sehrish30

Description

@sehrish30

Hi 👋 and thank you for the great work on this plugin!

Right now, the plugin stores cache keys based on the full request path, like:

GET:/api/blogs/blog%2Fjournal?locale=en-us

However, when deleting or updating an entity from a collection like api::blog.blog, the cache keys are not properly invalidated because they are tied to the request URL, while the mutation event typically only provides access to the entity ID.

I'd love to see support for cache key deletion that can be triggered based on:

  1. The collection UID (e.g., api::blog.blog)
  2. A key field (e.g., slug)

This would allow us to delete request-based cache entries tied to an entity even if the keys don't include the entity ID.

Inspiration from strapi-provider-rest-cache-redis

In strapi-provider-rest-cache-redis, each request-based cache key was tagged with entity metadata such as:

  1. collection:api::blog.blog
  2. entity:id:
  3. entity:slug:

This allowed the plugin to find and delete all cache entries related to a specific entity when it was updated or deleted — even if those cache keys were built from query strings or slugs

Suggested Improvement

When saving a cache key, optionally tag it with related metadata (collection UID, entity ID, and slug if applicable). On entity mutation, allow deleting all cache keys that match those tags.

Example flow:

  1. Cache key saved:
    key: GET:/api/blogs/blog%2Fjournal?locale=en-us Tags: [api::blog.blog, slug:blog/journal]

  2. On deletion of blog/journal:
    Automatically remove all cache keys tagged with slug:blog/journal and api::blog.blog

Use Case

If I delete a blog with the slug blog/journal, I want the plugin to automatically remove keys like:
GET:/api/blogs/blog%2Fjournal?locale=en-us

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions