Search code examples
c#asp.net-corecaching

How do I empty my browser's cache while my hosting server's cache is still stored?


We are utilizing the "MemoryCachingService" with the "Microsoft.Extensions.Caching.Memory" namespace in my project. I use the '_memoryCache' variable to store certain data. I understand from R&D that it will save server RAM, thus my first concern is: How can 1000 users of a web application distinguish themselves from one another? 2. How is storage organized and maintained? 3. Can I clear it from my browser?


Solution

  • Server-side cache is just a key/value store; since you are using the in-process memory version, this will consume server RAM, not "save" it - the point of cache is to reduce costs fetching repeated data, at the expense of holding data somewhere else (usually "cheaper"). It is not isolated by ... anything; if you want per-user data in the cache, you would need to use something unique about the user (their user id, typically) as part of the key, for example $"/u/{userid}/logical/data/path" (the key is simply opaque text).

    Cache is not in the browser, so I'm not sure what question 3 means.

    If you want system-implemented user isolation: maybe consider "session" data instead of cache.