I am working on REST API and I would really like to be able to use the same mechanism for responses as Drupal uses for cached content.
Unfortunately there is no render cache, everything is JSON responses. So there are no #ccache setting or page cache policy to be applied out of the box.
So I wonder if it is even possible and if so how should I approach it?
What I'm after basically is to cache the responses in the same manner as entities for example. So if the context is specific user and I am displaying entity information I would like to get fresh information if the entity is changed but the same content if not and the user is the same..and so on.