craftcms / element-api

Create a JSON API/Feed for your elements in Craft.
MIT License
498 stars 57 forks source link

[Help wanted] Element API Cache Key #55

Closed JoshStaff closed 7 years ago

JoshStaff commented 7 years ago

Hi all,

I'm creating an API for a react native app to consume and would like to do some cache busting in the background, I'm currently able to achieve the results I want with

craft()->cache->flush()

but that clears the entire entry cache, I would like to manually delete the element api cache but can't for the life of me work out what the key is. Is there anyone that can assist me?

Thanks

angrybrad commented 7 years ago

You can see the cache key being built here: https://github.com/craftcms/element-api/blob/v1/elementapi/controllers/ElementApiController.php#L59

It's a combination of elementapi: + the current URL path + : + the current URL query string. You'd want to use craft()->cache->delete() to delete specific keys instead of flush() which deletes everything.