outputcache

Expire Output Cache ASP.Net MVC

孤街醉人 提交于 2019-11-27 05:13:26
问题 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

OutputCache Location=Client does not appear to work

依然范特西╮ 提交于 2019-11-27 03:13:49
问题 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 " +

list OutputCache entry

喜你入骨 提交于 2019-11-27 02:02:04
问题 in my asp.net mvc application i'm using the OutputCache attribute on different action method. Is possible to view the current entries on the cache related to OutputCache attribute? If i cicle on System.Web.HttpContext.Current.Cache i don't find this type of entry. Thanks in advance F. 回答1: Output Cache is not publicly-accessible so you will not find it in System.Web.HttpContext.Current.Cache . In ASP.NET 2 it is contained in the CacheInternal 's _caches member, which you can guess by the name

Working with the Output Cache and other Action Filters

梦想的初衷 提交于 2019-11-26 22:24:25
问题 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

programmatically control output caching - disable or enable cache according to parameter value

白昼怎懂夜的黑 提交于 2019-11-26 19:44:55
问题 We've got a fairly standard e-commerce scenario with paged lists of products within categories. For better or worse, about 80% of visitors never navigate past the first page, depending on the category there may then be 5-10 more pages of results which are viewed far less often. (Yes we do optimise what appears on the first page and have good search - but that's a different discussion) We can't cache every single page of results, because we're constrained by memory, but the benefit of caching

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

孤人 提交于 2019-11-26 19:38:07
问题 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

Output caching for an ApiController (MVC4 Web API)

三世轮回 提交于 2019-11-26 19:33:34
问题 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

Clearing Page Cache in ASP.NET

*爱你&永不变心* 提交于 2019-11-26 15:07:35
For my blog I am wanting to use the Output Cache to save a cached version of a perticular post for around 10 minutes, and thats fine... <%@OutputCache Duration="600" VaryByParam="*" %> However, if someone posts a comment, I want to clear the cache so that the page is refreshed and the comment can be seen. How do I do this in ASP.Net C#? I've found the answer I was looking for: HttpResponse.RemoveOutputCacheItem("/caching/CacheForever.aspx"); The above are fine if you know what pages you want to clear the cache for. In my instance (ASP.NET MVC) I referenced the same data from all over.

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

大城市里の小女人 提交于 2019-11-26 13:58:38
问题 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

What&#39;s the best method for forcing cache expiration in ASP.NET?

给你一囗甜甜゛ 提交于 2019-11-26 08:30:18
问题 Suppose I have an ASP.NET application running across several web servers behind a load balancer: Can I: Force OutputCache (Page and/or Control level) to expire globally? Force Data Cache (i.e. Cache.Insert) to expire? Monitor ASP.NET caching usage (keys, RAM, etc) from a central location? One possible solution would be to have every usage of cache check a file dependency for changes. The file could be touched which would expire all cache. However, this requires developers to include the