title: Azure API Management response cache based on path parameter
body: <p>I need to implement business logic when the entire response is cached in APIM internally based on one path parameter. E.g. the URI is:</p>
  <pre><code>https://&lt;apimhostname&gt;/mycustomapi/v1/domains/&lt;domain_id&gt;/services
  </code></pre>
  <p>Based on <code>domain_id</code> path parameter, during the GET operation, I need to cache the entire response for specific <code>domain_id</code> and then return it back to the client during subsequent requests with given domain id. The number of possible domain_id values is less than 10.</p>
  <p>I see <code>vary-by-query-parameter</code> policy which caches the entire response per value of specified query parameters. But, in fact, I do not have query parameters. On the other side, there is <code>cache-store-value</code> policy which allows storing the value by key. In my case the key is <code>domain_id</code> but I am not sure whether it is possible to store the entire response in that way.</p>
  <p>Which approach is better to use in that case to cache the entire response based on path parameter?</p>
  <p>Also, I have an <code>Authorization</code> header with an access token that is validated (<code>iss</code> and <code>aud</code>) on APIM side (<code>validate-jwt</code> policy), however, my backend validates the 'roles' claim. So when I reply back with a response from cache are there any ways to validate the role claim on APIM side?</p>
  <p>Thanks.</p>