1

I've often seen the 'OutputCacheLocation.None' on the web like the following site.
http://msdn.microsoft.com/en-us/library/gg508808(v=vs.98).aspx

And I'm wondering if I should declare it, even if I did not explicitly indicates to make it to be cached.

4

3 に答える 3

1

Well the OutputCacheLocation is set by default to Any:

http://msdn.microsoft.com/en-us/library/hdxfb6cy.aspx

于 2012-04-23T05:14:31.193 に答える
1

No, there is no need. I do at least not use it.

I'm always writing:

[OutputCache(NoStore=true, Duration=0)]
public ActionResult MyAction()
{
}

However, I've never tried to exclude one of those properties. NoStore might be enough.

于 2012-04-23T05:21:25.940 に答える
0

This is not the only way to set the cache policy for MVC3.

You can also apply it on the action level. Or, directly write to the response:

response.setHeader( "Pragma", "no-cache" );
response.setHeader( "Cache-Control", "no-cache" );
response.setDateHeader( "Expires", 0 );

Check out more here: http://www.codeguru.com/csharp/article.php/c18745/ASPNET-MVC3-Caching.htm

于 2012-04-23T05:00:49.703 に答える