How to properly cache my Symfony2 APIs?

Viewed 2370

I'm making classic stateless RESTfull APIs on Symfony2: users/apps gets an authentication token on the authenticate API and give it to all others APIs to be logged and post data / access protected/private/personal data on others APIs.

I've got now three concerns regarding this workflow and caching:

  • How to use HTTP cache for my 'static' APIs (that always deliver the same content, regardless the logged user and its token) assuming that different tokens would be passed in the url by different users for the same API, so that the url would never be the same? How to use HTTP shared cache then?

  • I've got APIs for the same url that produce a different output, regarding the logged user rights (I've basically 4 different rights levels). Question is: is it a good pattern? It is not better to have 4 different urls, one for each right, that I could cache? If not, how to implement a proper cache on that?

  • Is shared HTTP Cache working on HTTPS? If not, which type of caching should I implement, and how?

Thanks for your answers and lights on that.

1 Answers
Related