Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is The Standard OutputCache Attribute Per User Or Per Application

If I add the following to my application/controller

[OutputCache(Duration = 7200)]

And I have two users on the site, User1 & User2. If User1 browses to a page with the above OutputCache turned on, the server caches the HTML in the page.

If User2 then requests the same page, does the server have to re-execute the page (because it is a different user) or does it use the same cached copy from when User1 accessed the page?

like image 497
YodasMyDad Avatar asked Mar 22 '23 00:03

YodasMyDad


1 Answers

It will use the same cache for all users. If you don't want the cache to be shared between users, you can:

  1. Don't use cache or selectively cache parts of the page thru donut or donut hole caching.

  2. Use the VaryByCustom parameter in the OutputCache attribute so that there is one cache per user but you usually don't need to cache things that only one user can see. See this

like image 69
LostInComputer Avatar answered May 03 '23 04:05

LostInComputer