outputcache

OutputCache Location=Client does not appear to work

我的梦境 提交于 2019-11-28 09:05:59
I am trying to use the OutputCache attribute in my MVC app and it doesn't appear to work when I use OutputCacheLocation.Client : public class HomeController : Controller { [OutputCache(Duration=15, Location=OutputCacheLocation.Client)] public ActionResult Client() { ViewBag.Message = "The current time is " + DateTime.Now.ToString("hh:mm:ss"); return View(); } [OutputCache(Duration=15, Location=OutputCacheLocation.Any)] public ActionResult Any() { ViewBag.Message = "The current time is " + DateTime.Now.ToString("hh:mm:ss"); return View(); } } The first one does not cache. I hit the page every

Vary by control properties using PartialCaching in ASP.NET

一曲冷凌霜 提交于 2019-11-28 05:32:57
I am using the PartialCaching attribute on the base class of a user control. I would like the cached controls to vary based on the properties set on the control instance. For example: <mycontrols:control1 runat="server" param1="10" param2="20" /> ...output would be cached separately from a control instance with different properties: <mycontrols:control1 runat="server" param1="15" param2="20" /> ...and this control would be cached separately as well: <mycontrols:control1 runat="server" param1="10" param2="25" /> However, if two control instances on two separate pages had identical param1 and

Expire Output Cache ASP.Net MVC

不羁的心 提交于 2019-11-28 03:52:11
I am using the standard outputcache tag in my MVC app which works great but I need to force it to be dumped at certain times. How do I achieve this? The page that gets cached is built from a very simple route {Controller}/{PageName} - so most pages are something like this: /Pages/About-Us Here is the output cache tag that is at the top of my .aspx view page just to be clear: <@ OutputCache Duration="100" VaryByParam="None" %> So in another action on the same controller where content is updated I need to dump this cache, or even all of it - it's a very small app so not a big deal deal to dump

Vary by control properties using PartialCaching in ASP.NET

谁都会走 提交于 2019-11-27 19:17:45
问题 I am using the PartialCaching attribute on the base class of a user control. I would like the cached controls to vary based on the properties set on the control instance. For example: <mycontrols:control1 runat="server" param1="10" param2="20" /> ...output would be cached separately from a control instance with different properties: <mycontrols:control1 runat="server" param1="15" param2="20" /> ...and this control would be cached separately as well: <mycontrols:control1 runat="server" param1=

How to turn output caching off for authenticated users in ASP.NET MVC?

给你一囗甜甜゛ 提交于 2019-11-27 18:51:26
I have an ASP.NET MVC application. I need to cache some pages however only for non-authenticated users. I've tried to use VaryByCustom="user" with the following GetVaryByCustomString implementation: public override string GetVaryByCustomString(HttpContext context, string custom) { if (custom == "user") { if (context.User.Identity.IsAuthenticated) { return context.User.Identity.Name; } else { return ""; } } return base.GetVaryByCustomString(context, custom); } However this isn't exactly what I need because pages are still cached. Only difference is that now is cached for each user separately.

Output caching for an ApiController (MVC4 Web API)

蹲街弑〆低调 提交于 2019-11-27 18:42:16
I'm trying to cache the output of an ApiController method in Web API. Here's the controller code: public class TestController : ApiController { [OutputCache(Duration = 10, VaryByParam = "none", Location = OutputCacheLocation.Any)] public string Get() { return System.DateTime.Now.ToString(); } } N.B. I'd also tried the OutputCache attribute on the controller itself, as well as several combinations of its parameters. The route is registered in Global.asax: namespace WebApiTest { public class Global : HttpApplication { protected void Application_Start(object sender, EventArgs e) { RouteTable

Why is output caching not working for my ASP.NET MVC 4 app?

◇◆丶佛笑我妖孽 提交于 2019-11-27 16:04:59
问题 I am having an issue where output caching doesn't appear to be working for my ASP.NET MVC 4 (EPiServer 7) website. I have the following output cache profile in my web.config : <caching> <outputCacheSettings> <outputCacheProfiles> <add name="PageOutput" enabled="true" duration="300" varyByParam="*" location="ServerAndClient" /> </outputCacheProfiles> </outputCacheSettings> </caching> And here is my output caching configuration for static resources: <caching> <profiles> <add extension=".gif"

Working with the Output Cache and other Action Filters

寵の児 提交于 2019-11-27 14:44:55
I have added Output Caching to a couple of actions in my app for some easy performance boosts. However, these actions also need to increment a counter after each request (it's a views counter) by hitting a Redis db. At first, I figured I could just adjust the order in which the action filters execute to ensure the view is counted: public class CountersAttribute : ActionFilterAttribute { public override void OnResultExecuted(ResultExecutedContext filterContext) { //increment my counter all clever like base.OnResultExecuted(filterContext); } } But that didn't work; apparently the

Why can't I combine [Authorize] and [OutputCache] attributes when using Azure cache (.NET MVC3 app)?

女生的网名这么多〃 提交于 2019-11-27 08:03:48
Using Windows Azure's Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider as the outputCache provider for an MVC3 app. Here is the relevant action method: [ActionName("sample-cached-page")] [OutputCache(Duration = 300, VaryByCustom = "User", Location = OutputCacheLocation.Server)] [Authorize(Users = "me@mydomain.tld,another@otherdomain.tld")] public virtual ActionResult SampleCachedPage() { return View(); } I get the following exception when loading this view from a web browser: System.Configuration.Provider.ProviderException: When using a custom output cache provider like

Does VaryByParam=“*” also read RouteData.Values?

早过忘川 提交于 2019-11-27 07:02:17
问题 in my asp.net mvc project, I enable output caching on a controller as below [OutputCache(Duration = 100, VaryByParam = "*", VaryByHeader = "X-Requested-With")] public class CatalogController : BaseController { public ActionResult Index(string seller) { // I do something } } it works great, until create my own Route class as below public class MyRoute : Route { // there is a constructor here.. // I override this method.. // just to add one data called 'seller' to RouteData public override