Closed lavkumarv closed 7 years ago
so how do you pass customerId to the API? Ideally it would be part of your URL, e.g. "api/v1/Customers/
Suppose I have 3 users and each user have different customers Eg.
user 1 => cus1, cus2, cus3
user 2 => cus4, cus5, cus6
user 3 => cust7, cus8, cus9
So by this endpoint
GET [Route("api/v1/Customers/")]
I will return all the customer of one user based on the token of the user. If the token is of user 1 then I will return all customer of user1. So problem is that URL will be same for all user only token will differ. How can I do caching for user specific?
In this case, for your vary parameters you need to choose the header containing the token. So in the constructor of the CachingHandler
, you can pass a param array of headers that the response can vary by (params string[] varyByHeader
). Let's say if it is by the Authorization
header, you pass "Authorization"
(along with any other parameter that can change) as an input.
Does this help?
I will try it. Thank you for your support:+1:
In my code, I have the end points like GET
[Route("api/v1/Customers/")]
This will return the customers for the user based on the token. (Each user have different sets of customers) So I want the user based caching. Does the Etag will be generated based on the client key?
If not So how can I do it?