Hello! I’m not sure if this qualifies as a feature request or a bug report (I believe it’s the former). I’m setting up a webhook to trigger on publish
events in a Record
to notify an API that revalidates tags on my server.
In my real scenario, I have a news item that can belong to either category A or category B, and each category has its own cache tag. When I publish a new news item in category A, a tag revalidation occurs to refresh the listing for category A. Same for B.
Now, imagine that I actually want to update a news item that’s already published, moving it from category A to category B. In this case, I want to be notified so that both caches can be revalidated. So I created a webhook like this:
- URL:
<domain>/api/v1/cache/revalidate
- Triggers: Record / Publish / Model “News”
- Body: custom payload
And my custom payload is something like this (compatible with my own API):
{ "tags": [
"news-category-{{entity.attributes.category}}",
"news-category-{{previous_entity.attributes.category}}"
] }
Note that I’m trying to pass 2 items: one with the category of the published item and one with the category of the previously published version. However, in this case, {{previous_entity}}
is undefined.
What would I like to see implemented?
For publish
events, it would be helpful if {{previous_entity}}
contained the data from the currently published version, and only be empty if there was no previously published version. It’s important to note that I expect only “published” versions to be compared, so the comparison should be “from published (before) to published (after).”
Currently, to work around this issue, I have to revalidate the entire cache. However, it would be highly beneficial if I could revalidate only the affected categories.
Important: I tried using the “update” events, but they are triggered when I save a record, which requests revalidation before it’s published, making the system ineffective anyway.
Thank you!