-
Notifications
You must be signed in to change notification settings - Fork 10
Description
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:
- The collection UID (e.g., api::blog.blog)
- 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:
- collection:api::blog.blog
- entity:id:
- 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:
-
Cache key saved:
key: GET:/api/blogs/blog%2Fjournal?locale=en-us Tags: [api::blog.blog, slug:blog/journal]
-
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