I'm having problems using the OutputCache attribute in Microsoft MVC3 environment.
Imagine the following controller action, which can be used as part of an AJAX call to get a list of products based on a specific manufacturer.
public JsonResult GetProducts(long manufacturerId)
{
return Json(this.CreateProductList(manufacturerId), JsonRequestBehavior.AllowGet);
}
I want this result to be cached on the server in order to avoid excessive database queries. I can achieve this by setting the attribute this way:
[OutputCache(Duration = 3600, Location = OutputCacheLocation.Server, VaryByParam = "manufacturerId")]
This works as I expected - the browser makes an insight request that forces the server to create and cache the result, subsequent requests from the same or another browser receive the cached version.
... , ; X, Y X, , X. , .
, OutputCache :
[OutputCache(Duration = 3600, Location = OutputCacheLocation.Client)]
: , ? Location ServerAndClient, , " ".
, "Vary: *", ServerAndClient, , .
- , , , - -...
.
PS: dev, IIS Express VS2010.