outputcache

ASP.NET (MVC) Outputcache and concurrent requests

ぐ巨炮叔叔 提交于 2019-12-05 18:53:26
问题 Let's say that, theoratically, I have a page / controller action in my website that does some very heavy stuff. It takes about 10 seconds to complete it's operation. Now, I use .NET's outputcache mechanism to cache it for 15 minutes (for examle, I use [OutputCache(Duration = 900)] ) What happens if, after 15 minutes, the cache is expired and 100 users request the page again within those 10 seconds that it takes to do the heavy processing? The heavy stuff is done only the first time, and there

ASP.NET OutPutCache VaryByParam and VaryByHeader with AJAX

你离开我真会死。 提交于 2019-12-05 18:32:34
问题 I'm trying to do some caching using VaryByParam AND VaryByHeader. When an AJAX request comes in I return a partial XHTML. When a regular request comes in I send the partial XHTML page with header / footer. I tried to cache the page by doing: [OutputCache( Duration = 5, VaryByParam = "nickname,page", VaryByHeader = "X-Requested-With" )] However this doesn't work... if I do a regular request first then run the AJAX call I get the full cached page instead of the partial and vice-versa. Seems

Bypass OutputCache in ASP.NET MVC

让人想犯罪 __ 提交于 2019-12-05 18:28:12
问题 I am using the OutputCache attribute in my MVC website as follows: [OutputCache(Duration = 5000, VaryByParam = "name;region;model;id;op;content;featured;isStarred;page;size;")] However sometimes I'd like to bypass the output cache entirely and force a fetch from the database. This is especially true for my test environment where I am continuously loading new data in to the database for testing. Is there anyway I could bypass the cache in this case? Thanks. 回答1: Instead of specifying all of

OutputCache is sending wrong Vary header when the call hits the cache

一笑奈何 提交于 2019-12-05 16:36:54
问题 I have an action method that I want to cache: [OutputCache(Duration=60*5, Location=OutputCacheLocation.Any, VaryByCustom="index")] public ActionResult Index() { return View(); } With this approach: public override string GetVaryByCustomString(HttpContext context, string custom) { context.Response.Cache.SetOmitVaryStar(true); context.Response.Cache.VaryByHeaders["Cookie"] = true; if (User.Identity.IsAuthenticated) { Debug.Print("Authenticated"); context.Response.Cache.SetNoServerCaching();

OutputCache attribute and jQuery Ajax not caching

扶醉桌前 提交于 2019-12-05 13:14:12
I have a simple MVC3 Controller Action like this [HttpGet] [OutputCache(Duration = 1200,Location=System.Web.UI.OutputCacheLocation.Server)] public string GetTheDate() { return DateTime.Now.ToString(); } And I call it from jQuery Ajax like this jQuery.ajax({ type: "GET", url: "http://localhost:60690/Public/GetTheDate", cache: false, success: function (data) { //alert("success"); jQuery("#stats").append("<b>" + data + "</b>"); }, error: function (req, status, error) { alert("failure"); alert(error + " " + status + " " + req); } }); The problem is that the date is always the current date, not the

Outputcache doesn't work with routing

妖精的绣舞 提交于 2019-12-05 07:25:17
问题 I'm using routing from System.Web.Routing without MVC in a standard ASP.Net Web Application Project application. This is mostly done to get neater urls in the portal we are developing (instead of ~/default.aspx?contentid=123 we have ~/{contentsubject}. The portal is not authorized and all info is in the url so in a caching scenario we can cache complete pages. When I tried to enable output caching I noticed that no caching was done. It seems that the outputcache page directive is completely

How best to work with the Expires header in ASP.NET MVC?

我的未来我决定 提交于 2019-12-05 06:53:16
I want to be able to set a long expires time for certain items that a user downloads via GET request. I want to say 'this is good for 10 minutes' (i.e. I want to set an Expires header for +10 minutes). The requests are fragments of HTML that are being displayed in the page via AJAX and they're good for the user's session. I don't want to go back to the server and get a 304 if they need them again - I want the browser cache to instantly give me the same item. I found an article which is almost a year old about MVC Action filter caching and compression . This creates a custom ActionFilter to

mvc3 OutputCache RemoveOutputCacheItem RenderAction

痴心易碎 提交于 2019-12-05 04:55:56
I did my research but haven't found any answers. I'm using Html.RenderAction in a masterpage ( to render page header with links specific to user permissions ). Action is decorated with OutputCache, returns partial control and gets cached as expected. When the event happens ( let's say permissions are changed ) I want to programmatically invalidate cached partial control. I'm trying to use RemoveOutputCacheItem method. It takes a path as a parameter. I'm trying to set the path to the action used in Html.RenderAction. That doesn't invalidate the action. How can I programmatically invalidate the

ASP.NET MVC hits outputcache for every action

拈花ヽ惹草 提交于 2019-12-04 21:21:38
问题 We are running quite a large site build with ASP.NET MVC 3 and AppFabric as a distributed caching solution. We have implemented a custom OutputCacheAdapter to use our AppFabric cluster. We are seeing that ASP.NET calls the OutputCacheProvider.Get() method for every action, even if that action is NOT decorated with a @OutputCacheAttribute. That isn't much of a problem if you use the default outputcacheprovider but it is when you are running an outputcacheprovider that resides on seperate

ASPX That Returns An Image - Output Cache-able?

混江龙づ霸主 提交于 2019-12-04 13:18:19
问题 Greetings! I've created an APSX web form that returns a remote image based on some supplied parameters. It can be used like this: <img src="/ImageGetter.aspx?param1=abc&param2=123" /> ImageGetter.aspx's markup and code look similar to this: <%@ OutputCache Duration="100000" VaryByParam="*" Location="ServerAndClient" %> <%@ Page Language="C#" AutoEventWireup="false" EnableSessionState="False" CodeBehind="ImageGetter.aspx.cs" Inherits="ACME.Helpers.ImageGetter" %> This code is called in