I'm replacing some templates with the ElementAPI plugin.
In my templates, I would use the cache
tag, and rely on Craft to handle invalidation when the elements changed.
How can I achieve a similar thing now that I'm using the ElementAPI plugin?
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It only takes a minute to sign up.
Sign up to join this communityI'm replacing some templates with the ElementAPI plugin.
In my templates, I would use the cache
tag, and rely on Craft to handle invalidation when the elements changed.
How can I achieve a similar thing now that I'm using the ElementAPI plugin?
The ElementAPI plugin itself doesn't seem to offer a caching solution, but there is a fork from a guy which has implemented a caching option cache
and cacheTime
:
https://github.com/theolampert/ElementAPI
Update: They have introduced a new cache
option in the official ElementAPI plugin (version 1.5).
I was also very interested in this, so i forked the repo from theoplampert and added some extra features. You can find it here, https://github.com/jacobnijgh/ElementAPI. This fork allows you to not only cache the results but also the paginated results just what we needed in our case for loading some results with AJAX.