outputcache

How Do I prepopulate the outputcache in an asp.net web application?

I'm using an outputcache page directive to cache values based on VaryByParam. Is there a way I can prepopulate the cache when the web application starts up for a set of common params, instead of having to wait for a user to hit the page? Or do I just need to write a script that hits all the pages I want cached? Ideally, I can do it serv...

Output Caching pages with user specific information

We have several sites that are mostly content managed using a sql database backend. these sites are most of the time serving up static information unless users change the content by voting or updating (similar to SO). These sites all have master pages where user specific information is often displayed at the top of each page (also simi...

how to remove OutputCache programmatically for ascx?

I have a page1.aspx: <%@ Register src="uc1.ascx" tagname="UcHead" tagprefix="uc1" %> and uc1.ascx using the OutputCache: <%@ OutputCache Duration="18000" VaryByParam="*" %> How can I click a button in another page2.aspx to remove OutputCache for uc1.ascx or page1.aspx? When the OutputCache is in page1.aspx, I can use the following...

recent items display - caching technique?

We have an ASP.NET application in which on the master page we have a user control that displays the most recently accessed entities by the user. To prevent database trips for every page load, we have enabled the caching for this user control by setting the outputcache directive as follows: <%@ OutputCache Duration="1200" Shared="true" ...

Outputcache - how to determine optimal value for duration?

I read somewhere that for a high traffic site (I guess that is a murky term as well), 30 - 60 seconds is a good value. Obviously I could do a load test and vary the values, but I couldn't find any kind of documentation on this. Most samples have a minute, a couple of minutes. There's no recommended range. Is there something on msdn or...

ASP.NET MVC: Problem with OutputCache

Hi, for my current project it's necessary to generate dynamic CSS... So, i have a partial view which serves as a CSS deliverer... The controller code looks like this: [OutputCache(CacheProfile = "DetailsCSS")] public ActionResult DetailsCSS(string version, string id) { // Do something with the version and id here.....

InvalidCastException: System.Web.UI.PartialCachingControl -> MyCustomControl when OutputCaching

The problem: I am unable to use OutputCaching with my controls which derives from MyCustomControl. Controls are loaded dynamically using definitions from database with Page.LoadControl method. When I add to ascx <%@ OutputCache VaryByParam="*" Duration="3600"%> the "InvalidCastException: System.Web.UI.PartialCachingControl -> MyCustom...

ASP.NET MVC OutputCacheAttribute: do not cache if a parameter is set?

I have the following action: public class HomeController : Controller { public ActionResult Index(int? id) { /* ... */ } } I'd like to [OutputCache] that action, but I'd like that either: it doesn't use the cache if id == null; or it uses the cache if id == null but with a different duration. I think I can achieve this by: pu...

ASP.NET output caching - dynamically update dependencies

Hi All, I have an ASP.NET application which requires output caching. I need to invalidate the cached items when the data returned from a web service changes, so a simple duration is not good enough. I have been doing a bit of reading about cache dependencies and think I have the right idea. It looks like I will need to create a cache d...

Asp.net mvc output cache don't work with RedirectToAction.

For my case, i have a controller, which query then forward the user using RedirectResult, which actually did a header "Location". Then i apply the cache to the controller like this [OutputCache(Duration = int.MaxValue, VaryByParam = "none", NoStore=false)] I try to re-run the page, and I check on my Linq profiler, I still able to see...

Is it possible to use OutputCache on mvc JsonResult controller methods?

I am trying to do this, and it leads to result with contentlen 0 It looks like: [OutputCache(Duration = 36000)] public JsonResult GetFileClasses() { return this.Json(TopicConfig.FileExtensionsSettings.List) } Any ideas? ...

Is there a way to have OutputCache ignore the master page in asp.net mvc?

I have an action that returns a view with a master page with a logon user control at the top. When I set outputcache, it caches the entire output including the current user, so everybody would see whoever was the last person to hit the page to refresh the cache as the current user. Is there a way to prevent the master page from being i...

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

I have an ASP.NET MVC application. I need to cache some actions (pages) however for some pages I need do such only for non authenticated users. I've tried to user VaryByCustom="user" with following GetVaryByCustomString implementation. public override string GetVaryByCustomString(HttpContext context, string custom) { if (custom == "u...

ASP.NET (MVC) Outputcache and concurrent requests

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...

How do I cache at both client & server when VaryByParam != "none"?

I'm looking for a way to cache a page at both the client and the server while varying the server's output cache by a querystring parameter "Version". With this tag: <%@ OutputCache Duration="10" Location="Any" VaryByParam="none" %> I get these headers: HTTP/1.1 200 OK Cache-Control: public Content-Type: text/html; charset=utf-8 Expi...

Outputcache doesn't work with routing

Hi, 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 ...

When OutputCaching is enabled and the session is in SqlServer, the database is hit on every request?

If I had two servers using a single sqlserver instance as the session state, and I enable outputcache in the page, do you know if the database is hit on every request? Since the outputcache is being used to respond the request, I asume is not needed, but if the session is being retrieved before the outputcache flag is checked, then the ...

Output Cache problem on ViewEngine that use 2 separate view for 1 controller

http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx To the sake of simplicity, please try out this. Basically, I am trying to do the mobile view engine, but then i found out that I have outputcache, which will cache one of 2 view (PC view) and then when i tried to access through mobile, it ...

Outputcache returns invaid version with postback

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 ...

How can I view the contents of the ASP.NET OutputCache?

Is there any way that I can list the pages which are currently stored in the OutputCache? Just a list of paths would do, but if there's a way to get more information about each item (expiry etc), then all the better. ...