HttpCaching - ETag generated per client or per token?

374 views Asked by At

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 :

  1. There is one table named 'dataTable' which includes field named 'email'.
  2. I have identity tables so users are in aspnetUser table.
  3. Data retrieved based on logged user email address (where dataTable.email = current principle.Identity.Name).
  4. dataTable includes 10 records. 9 records for user1 and only 1 record for user2.
  5. I used 'Postman Rest Client' to test and logged 2 users. So i have 2 tokens for logged users.

Clarifications:

  1. 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);
  1. 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
0

There are 0 answers