I am working in ASP.NET WEB API with oAuth2 bearer token authentication and HttpCaching with CacheCow.
The implementation already done and i am verifying the code and got confused with caching.
Cache Handler Configuration:
The cache configuration code is below;
var connString = ConfigurationManager.ConnectionStrings["myContext"].ConnectionString;
var sqlServerEtagStore = new InMemoryEntityTagStore();
var cacheHandler = new CachingHandler(config, sqlServerEtagStore);
config.MessageHandlers.Add(cacheHandler);
Scenarios and working steps :
- There is one table named 'dataTable' which includes field named 'email'.
- I have identity tables so users are in aspnetUser table.
- Data retrieved based on logged user email address (where dataTable.email = current principle.Identity.Name).
- dataTable includes 10 records. 9 records for user1 and only 1 record for user2.
- I used 'Postman Rest Client' to test and logged 2 users. So i have 2 tokens for logged users.
Clarifications:
- From configuration, i think sqlserver is configured for persistent storage. But after used InMemoryEntityTagStore. Why this.? so configuration is wrong? What in 'InMemoryEntityTagStore' class?
var sqlServerEtagStore = new InMemoryEntityTagStore(); var cacheHandler = new CachingHandler(config, sqlServerEtagStore);
- From scenario, I used get request to get data with user1 token. Here i got 9 records with etag generated. Then i request to get data with user2 token. Here also i got the same etag. is this correct? so eTag is generated per client? is my testing scenario is worng? i thought like for each resource separate tag is generated so data based on user is cached