outputcache

OutputCache for dynamic pages with state

I have an ASPX page that makes a lot of database queries that I am trying to cache to improve performance of the application. The page can be one of three states: Waiting for dynamic data. Displaying dynamic data. Done displaying dynamic data. The DateTime for the dynamic data is stored in the object that you load with the "Id" GET p...

Using ASP.NET MVC OutputCache while varying View content based on whether user is authenticated

I'm building an ASP.NET MVC 2 site where I'm using the OutputCache parameter heavily. However, I have a concern: using such caching may interfere with authentication. On all of my pages, I display whether the user is logged in or not. Furthermore, in some of my Views, I do filtering based on user role to determine whether or not to disp...

How to set the S-MaxAge CacheControl value in an ASP.NET app?

Hi folks, I'm trying to set the cachability of an ASP.NET resource. So if I goto /foo/show it will show a View for some resource, and cache this for a few hours (for example). To do this, I'm using the OutputCache attribute which decorates my Action Method. The details of this cache (against this action method) are found in the web.conf...

Invalidate portions of the asp.net mvc output cache - with varying levels of granularity

I'm a little confused about the granularity offered by the HttpResponse.RemoveOutputCacheItem() call. I'm interested in performing some output caching on dynamically-generated images, and would like to vary the output cache using at least to paramaters (let's call them 'id' and 'size' for argument's sake). So, for example: /Image/User...

asp.net ajax control toolkit vs OutputCache

Hello, I wanted to use the star rating control from ajax control toolkit library but my aspx page has OutputCache set. It seems they don't play well together. I tried moving the StarRating control into a user control that has no caching but it made no difference. Could anyone give advice for a workaround. Is there any way to make this...

Remove Output Cache Programatically

Hi All,i want to ask about the way to expire the output caching of a specific page programatically regardless the expiration duration. I found several posts and articles online regarding this issue and i found on this article that this line of code does the work HttpResponse.RemoveOutputCacheItem("/caching/CacheForever.aspx"); i trie...

How do I use VaryByParam with multiple parameters?

In ASP.NET MVC2 I use OutputCache and the VaryByParam attribute. I got it working fine with a single parameter, but what is the correct syntax when I have several parameters on the method? [OutputCache(Duration=30, VaryByParam = "customerId"] Public ActionResult Index(int customerId) { //I've got this one under control, since it only ha...

Cache page but count hits

I have an aspx page which counts every visit and creates a cookie. But if I use OutputCache page counts only the first visitor who requested the page. How can I prevent this bug? Page directive: <%@ OutputCache Duration="1200" VaryByParam="mode;page;sid;tid" %> Codebehind: protected void Page_Load(object sender, EventArgs e) { /...

Is it possible to modify the default outputcache settings

I'm trying to do something similar to this question, I have a multitenant application and want to configure the output cache to be per tenant. However i'd rather not have to use a custom outputcacheattribute or have an outputcache profile and remember to use this everywhere. Is it possible to change the default outputcache profile setti...

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

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

Prevent returned view being cached when an error occurs

Is there a way to to prevent a page from being cached when the OutputCache attribute has been set on an action? This is so that, when the page is subsequently hit, it will not store the generic error page that was returned previously. An example below shows an instance where it would be desirable for the application not to cache the pa...

Output caching a custom control (server control)

Hi, I've come across hints about output caching a server control, but have yet to find a definitive answer to: Can the output of a server control be cached (in the same way that user controls are cached)? The suggestions I've come across involve caching the data (not true output caching), or suggest setting the response.cache options. ...

Get current OutputCache profile

In my ASP.NET MVC application I have a custom cache provider inherited from base OutputCacheProvider class. Is there any way to get output cache profile for current request in my provider? ...

Optimal Storing of Cache File References with Cache Tags in MySQL

Background I've got a complex page caching system in place. Every database item that is used on a page stores a reference related to the item and the cached page. Below is the database table used to store those cached references CREATE TABLE `sacrifice_cache` ( `cache_id` int(21) NOT NULL AUTO_INCREMENT, `cache_page_id` varchar(255...

MVC OutputCache issue

I am trying to cache the output of a controller action in MVC2 like this: [OutputCache(Duration = 600, VaryByParam = "id", Location=System.Web.UI.OutputCacheLocation.Server)] public FileContentResult GetImage(int id) { } When the user uploads a new image for their icon I invalidate the cache using the following line: HttpResp...

ASP.NET: Setting a cookie in a cached page

How do I set a cookie on a page, base on a query-string-value, if the page is returned by the Output-cache? I have a page with this output-cache: <%@ OutputCache VaryByParam="cookievalue" ... And I have this code in the Global.asax's *Application_BeginRequest*: // Validation and checkings HttpCookie cookie = new HttpCookie("__cookie...

Issue with ASP .Net MVC 2.0 Caching

I am using OutputCache on an Action like this: [OutputCache(Duration = 14400, VaryByParam = "none")] public ContentResult Catalog() { return ...; } and my RegisterRoutes function in Global.asax.cs contains the route: routes.MapRoute( "XMLRoute", // Route name "{site}/catalog.xml", // URL with parameters new { controller ...

ASP.Net output caching annoyance

In our ASP.Net site we only allow users in from certain countries by checking and filtering their IP address by range. One of the features of the site is we have a bypass IP check query string argument. This argument just sets a bypass cookie in case they click other links beyond the initial landing page which we can check to keep the by...

Urls get corrupted with Outputcache when folder changed

I noticed serious bug with outputcache on user control level. Code is as simple as <a runat="server" href="~/App/View/Login.aspx">Login</a> When first page domain.com/App/View/login.aspx all is fine and I see getting link like domain.com/App/View/Login.aspx In output I see following HTML: <a href="Login.aspx">Login</a> But then...

What's the current practice for partial caching in ASP MVC2?

My website pages are composed of two kinds of content. The first is variable between users but constant for all pages. The second is constant across users, but variable between pages. This is a common layout. What is the best way to apply output caching to content like this? As I understand it, the Html.Substitute helper is incompatible...