Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Cache clearing CLI and/or utility #136

Closed
yoannisj opened this issue Sep 9, 2020 · 1 comment
Closed

[FR] Cache clearing CLI and/or utility #136

yoannisj opened this issue Sep 9, 2020 · 1 comment

Comments

@yoannisj
Copy link
Contributor

yoannisj commented Sep 9, 2020

Description

It would be great to add a craft CLI command and/or a checkbox in the CP's clear-caches utility, to clear all element-api caches. This action could then be triggered on deployments and element change related events (save, publish, expire, etc.).

Currently, the only way to clear element-api caches reliably is to flush all data caches with Craft::$app->getCaches()->flush(), but this is a bit aggressive as it potentially clears cache entries from other plugins (and I believe as of Craft 3.5 also rendered template caches).

A less aggressive approach would be to clear the cache entry for a given element when it gets saved (probably also when an entry gets published or expires), as suggested here, but this won't work if an endpoint returns related element data (when the related element gets saved, getting the cache key for each and every endpoint where this element is included can quickly become quite tricky).

For this use case (not so uncommon in my own experience for what it's worth), I believe linking the element-api cache to element query caches (similar to how template caches are handled) would be the most efficient approach.

Relate issues #47, #55, #122

@brandonkelly
Copy link
Member

Just released Element API 2.7.0, which adds the ability to clear Element API response caches from the Caches utility, or via the craft invalidate-tags/element-api command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants