craftcms / element-api

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

Caching #31

Closed jan-thoma closed 7 years ago

jan-thoma commented 7 years ago

Adding the possibility to cache the json files would be be great

aaronbushnell commented 7 years ago

Agreed. Would really like to use this plugin to generate API endpoints, but I'd prefer if it were possible to get the data from cache instead from the database on each request.

brandonkelly commented 7 years ago

Thoughts on implementation? Maybe just a cache endpoint config setting that you set to a interval spec, and future requests will just use the cached response until the cache expires?

aaronbushnell commented 7 years ago

I think that would be great, @brandonkelly! That would cover my main hesitation here.

What would be really great is if a change to one of those entries busted the cache, too. That'd likely add a great deal of complexity so I understand if it isn't in scope for this project.

brandonkelly commented 7 years ago

Haha yeah I’m out of the cache-busting business :)

aaronbushnell commented 7 years ago

Ha! I don't blame you guys one bit!

I think allow a simple date mechanism (wipe the cache every X duration) is sufficient for my needs.

brandonkelly commented 7 years ago

Element API 1.5.0 for Craft 2, and 2.3.0 for Craft 3, are out now with a cache endpoint config option.

aaronbushnell commented 7 years ago

This is awesome. Thanks a ton, @brandonkelly!