outputcache

How to set different Cache expire times for Client and Server caches

雨燕双飞 提交于 2019-12-03 05:38:43
I would like to have certain pages have a 10 minute Cache for clients and 24 hours for the server. The reason is if the page changes, the client will fetch the updated version within 10 minutes, but if nothing changes the server will only have to rebuild the page once a day. The problem is that Output Cache settings seem to override the Client settings. Here is what I have setup: Custom ActionFilterAttribute Class public class ClientCacheAttribute : ActionFilterAttribute { private bool _noClientCache; public int ExpireMinutes { get; set; } public ClientCacheAttribute(bool noClientCache) {

OutputCache behavior in ASP.NET MVC 3

眉间皱痕 提交于 2019-12-03 04:34:46
问题 I was just testing Output Caching in the RC build of ASP.NET MVC 3. Somehow, it is not honoring the VaryByParam property (or rather, I am not sure I understand what is going on): public ActionResult View(UserViewCommand command) { Here, UserViewCommand has a property called slug which is used to look up a User from the database. This is my OutputCache declaration: [HttpGet, OutputCache(Duration = 2000, VaryByParam = "None")] However, when I try and hit the Action method using different 'slug'

Setting optimum http caching headers and server params in ASP.Net MVC and IIS 7.5

女生的网名这么多〃 提交于 2019-12-02 22:40:18
I have an ASP.Net site (happens to be MVC, but that's not relevant here) with a few pages I'd like cached really well. Specifically I'd like to achieve: output cached on the server for 2 hours. if the file content on the server changes, that output cache should be flushed for that page cached in the browser for 10 minutes (i.e. don't even ask the server if it's that fresh) when the browser does make an actual subsequent request, I'd like it to use etags, so that the server can return a 304 if not modified. (note - time values above are indicative examples only) 1) and 2) I can achieve by

OutputCache behavior in ASP.NET MVC 3

自古美人都是妖i 提交于 2019-12-02 18:53:21
I was just testing Output Caching in the RC build of ASP.NET MVC 3. Somehow, it is not honoring the VaryByParam property (or rather, I am not sure I understand what is going on): public ActionResult View(UserViewCommand command) { Here, UserViewCommand has a property called slug which is used to look up a User from the database. This is my OutputCache declaration: [HttpGet, OutputCache(Duration = 2000, VaryByParam = "None")] However, when I try and hit the Action method using different 'slug' values (by manupulating the URL), instead of serving wrong data (which I am trying to force by design)

OutputCache returns invalid version with PostBack

感情迁移 提交于 2019-12-02 01:40:32
I am having a weird issue happening with outputcache. I have multiple user controls on a page, one of which is a login control. The page and the login control is NOT cached, but other user controls are cached with VaryByParam. Now all of this works along with caching when I click on to different pages. But as soon as I login, other user controls on that page display old cached versions. If I refresh the page, I get the correct cached version of all user controls. The problem is only when a postback happens. For some reason on a postback, the cached version returned does not take into account

Output cache in content and master page

半腔热情 提交于 2019-12-02 00:50:36
问题 Two questions: 1. If I have a content page and a master page and I put this inside my content page: <%@ OutputCache ...%> Does it cache the whole page or only the content page portion? 2. How can I apply OutputChace in the master page? I have a master page that has a lot of content pages that uses it. I want to apply the same outputcache profile on all of them, but I dont want to go one by one and change them. Thanks. 回答1: The whole page is cached. Edit You can use user controls to cache

Outputcache attribute on clientside with partial pages'

爷,独闯天下 提交于 2019-12-01 20:55:54
问题 I a partial page creating the menu for application. I am calling the menu partial view using renderaction. I want to store this partial page on client side by doing this [OutputCache(Duration=7200, Location =OutputCacheLocation.Client, NoStore= true)] but i am getting the following error OutputCacheAttribute for child actions only supports Duration, VaryByCustom, and VaryByParam values. Please do not set CacheProfile, Location, NoStore, SqlDependency, VaryByContentEncoding, or VaryByHeader

OutputCache and Authorize filters in MVC3

非 Y 不嫁゛ 提交于 2019-12-01 20:17:47
问题 I am reading a book about MVC2, and in the OutputCache section it states: Warning In the earlier section “How Authorization Filters Interact with Output Caching,” I explained that [Authorize] has special behavior to ensure that unauthorized visitors can’t obtain sensitive information just because it’s already cached. However, unless you specifically prevent it, it’s still possible that cached output could be delivered to a different authorized user than the one for whom it was originally

Outputcache attribute on clientside with partial pages'

老子叫甜甜 提交于 2019-12-01 18:24:19
I a partial page creating the menu for application. I am calling the menu partial view using renderaction. I want to store this partial page on client side by doing this [OutputCache(Duration=7200, Location =OutputCacheLocation.Client, NoStore= true)] but i am getting the following error OutputCacheAttribute for child actions only supports Duration, VaryByCustom, and VaryByParam values. Please do not set CacheProfile, Location, NoStore, SqlDependency, VaryByContentEncoding, or VaryByHeader values for child actions Any alternate to this Client side caching is not possible for partials in MVC 3.

How to remove OutputCache on ChildAction?

烈酒焚心 提交于 2019-12-01 05:48:22
I am trying to take advantage of the donut caching features in .Net MVC 3. For my Home page, in my home controller, I have: public ActionResult Index() { return View(); } [ChildActionOnly] [OutputCache(Duration=3600)] public ActionResult IndexMain() { return PartialView(ViewModelRepository.GetIndexViewModel()); } I my view, I have: <% Html.RenderAction("IndexMain");%> This all works fine. However, when the data changes, I run: var urlToRemove = Url.Action("IndexMain", "Home"); Response.RemoveOutputCacheItem(urlToRemove); The RemoveOutputCacheItem executes without an error, but the ChildAction