-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Problem to solve
W3C requested if it's possible to automatically generate cache tags based on IDs of entries. For example for the homepage add cache tags for the news items with their ids, e.g.
- pressReleases-67093
- blogPosts-56297
- newsArticles-56870
- newsArticles-56872
Which then allows us to clear the cache in the CMS based on the above cache tag, which makes this a bit more flexible.
Example data
For the example of the homepage recent activity, returned data looks like:
{
"id": "67093",
"sectionHandle": "pressReleases",
},
{
"id": "56297",
"sectionHandle": "blogPosts",
},
{
"id": "56870",
"sectionHandle": "newsArticles",
}
Possible solutions
We probably need some form of processing function to extract the "id" and prefix a cache tag based on the sectionHandle
E.g.
$query->addItemCacheTags('[sectionHandle]', '[id]')
Which would generate cache tags based on concatanating the passed property paths separated by "-"
This could either be applied to the query (simpler, since that's where other cache functions are) or a separate function to process the returned data.