Outputcache - Dynamically Update Dependencies?

Jan 13, 2010

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 dependency to my web service.To associate the page output with this dependency I think I should use the following method:

Response.AddCacheItemDependency(cacheKey);

The thing I am struggling with is what I should add to the cache?

The dependency my page has is to a single value returned by the web service. My current thinking is that I should create a Custom Cache Dependency via subclassing CacheDependency, and store the current value in the cache. I can then use Response.AddCacheItemDependency to form the dependency.

I can then periodically check the value and for a NotifyDependencyChange in order to invalidate my cached HTTP response.The problem is, I need to ensure that the cache is flushed immediately, so a periodic check is not good enough. How can I ensure that my dependant object in the cache which represents the value returned by the web service is re-evaluated before the HTTP response is fetched from the cache?

View 2 Replies


Similar Messages:

MVC :: How To Add Dependencies To Output Cache Dynamically

Sep 9, 2010

Suppose i have an controller action that i would like to output cache.

public class HomeController : Controller
{
[OutputCache(Duration=10, VaryByParam="none")]
public ActionResult Index()[code]....

I need to dynamically set dependency to an external file inside the code. How can i do that?

View 2 Replies

How To Insert Dependencies Dynamically In View (Javascript And CSS Files)

Apr 7, 2010

I am willing to follow the rules of the W3C where it is recommended that javascript and CSS files should be in individual files and not within the page.

Good, following this rule, and not wanting to overload the master page, I would like to embed the dependencies dynamically. So how could I insert the libraries dynamically? I think the bigger problem is the Ajax requests.

Example:

<script type="text/javascript" src="http://sstatic.net/so/js/master.js?v=6523"></script>

I tried using the JavascriptResult, but he writes the content on the page, and do not run as "Stream."

View 2 Replies

Web Forms :: Remove OutputCache In Server Or Update ?

Nov 22, 2010

I Want data OutputCache in server remove

View 2 Replies

C# - Dynamically Update Attributes Of ASP Controls Dynamically?

Sep 2, 2010

In my aspx page, I have a number of drop down controls. I would like to update an attribute on each of the controls with "class=leftColumn" with the following line: propertyID.Attributes["nameOfAttribute"] = "false";
But instead of manually writing out each controlID and setting its attribute with the line above, I had hoped there was a way to go through and set the attribute on each control ID if it had class=leftcolumn. This is something I know is very easy with JQuery, BUT I need to do it with the code behind (C#) I was told this is not possible (i.e. to acquire a list of all the controls and then iterate through the list and give it the attribute or any other way. That manually setting each control like the above example is the only way in ASP.NET.

View 2 Replies

Web Forms :: What Is The Use Of OutputCache

Oct 5, 2010

<%@ OutputCache Location="None" VaryByParam="None" %>

Because when am using this line in http then the attachment is opening fine but not for https.But after removing this line then https is working fine.

View 6 Replies

C# - Using Outputcache Together With Urlrewriting

Mar 31, 2011

I've got a problem using outputcache together with urlrewriting. We've got an application that rewrites url (IE [URL]). Based on the URL (/about/) we figure out which content to show. Now we're trying to add outputcache to that page:

< %@ outputcache duration="600" location="Server" varybyparam="Custom" varybycustom="RawURL" %>

And in the Global.asax we override GetVaryByCustomString like below:

public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom == "RawUrl")
{
return context.Request.RawUrl;
}
else
{
return string.Empty;
}
}

However, when we publish the page i'd like to invalidate the cache so that the editors see the change directly. But no matter what I try, I cannot seem to invalidate the cache. If I'd like to invalidate "/about/" I would like to do this: HttpResponse.RemoveOutputCacheItem("/about/"); That doesn't work unfortunately. The only thing that seems to work is: HttpResponse.RemoveOutputCacheItem("/page.aspx");

This clears the cache for all my pages, not just "/about/". Is there any way to invalidate the cache based on the url? Or should we provide a cache key or something per page to be able to invalidate the cache programmatically?

View 1 Replies

MVC :: OutputCache / RenderAction And SEO?

Jan 29, 2010

I read many posts about outputcaching element in asp .net MVC, but i have one question.My architecture is :1 master page, 1 page (especially news information), and a few other controls like LogOnUser / Fixed status bar etc...I want to have my news cached cause there are three query to entities, but i need too the title for SEO of my master page (title is included in a contentplaceholder in master).I tried to use renderaction outputcache but it is not possible to retrieve the title from the renderaction. Have you any idea about this problem ?Maybe it's preferable to use a general outputcache and use a substitute from dynamic data, but i don't know if it's a best practice or not.

View 1 Replies

How To Use Cache Dependencies In MVC

Oct 22, 2010

How to use cache dependencies in MVC?So far, I follow the caching tutorial (http://weblogs.asp.net/rashid/archive/2008/03/28/asp-net-mvc-action-filter-caching-and-compression.aspx) but what if changes occured in the database and the page is still cached. [:(]

How to clear cached pages when new data is inserted?

View 4 Replies

How To Invalidate The OutputCache In A Webform

May 3, 2010

i've got a website that uses OutputCache attribute to cache pages. Works great.

Now, I'm in the middle of R&D'ing scaling up this site to be in a web farm. Along with the usual suspects for webfarm pain ... I've noticed (pretty quickly/obviously) that the OutputCache from Server_A doesn't invalidate the OutputCache from Server_B .. if a try and invalidate a single server's OutputCache. This makes total sense -> how can S_A 'tell' S_B to invalidate when they are physically 2 seperate machines, etc?

So - what are our options?

Velocity? I understand this will move the caching to a different layer .. which means that the final result (output) will always be required to be determined .. as opposed to the OutputCache whic remembers the final output content (yes, varby gives different versions, etc.. which is totally fine). So even though the poco or business objects are all sync'd, there's still that last rendering effort required (even if it's tiny .. compared to the effort to generate/sync business objects).

View 2 Replies

Web Forms :: Set OutputCache Dynamicllly?

Feb 15, 2011

i have CMS that dynamically add user control to page. now i wanna use OutputCache for user control and set it from server side code. how i can do that?

View 1 Replies

MVC :: OutputCache Varyby IsAjaxRequest?

Jan 11, 2010

I've an action in a controller that returns different content if the request is Ajax or not:

[Code]....

So, from the view I can fill a <div> with the PartialView (RenderPartial), calling the same action (allowing javascript disabled clients). The problem is the cache, because when the request has cached as a normal request, if later sends the request as an Ajax request, the view is rendered very bad.

The question is: Is there any way to use OutputCache to allow to cache in different entries this two types of requests (Ajax and not Ajax).

View 4 Replies

AJAX :: ModalPopupExtender With OutputCache

Mar 1, 2011

I have a user control with OutputCache set to vary by any param (*). This user control has a LinkButton, which when clicked, causes a postback, and displays a ModalPopupExtender (the extender's TargetControlID is a dummy link). The user control is included on an aspx page.

The LinkButton is displaying the popup just fine. But if I open another browser tab/window/type, the LinkButton fails to generate the popup. I've tried (all separately):

moving the popup extender and its associated control to the main aspx page use OutputCache Location="None" on main page dynamically create the Popup extender and its associated control in Page_Init of both ascx and aspx

View 2 Replies

C# - Enable OutputCache With An IHttpHandler?

Apr 22, 2010

I have an IHttpHandler that I would like to hook into the OutputCache support so I can offload cached data to the IIS kernel. I know MVC must do this somehow, I found this in OutputCacheAttribute:

public override void OnResultExecuting(ResultExecutingContext filterContext) {
if (filterContext == null) {
throw new ArgumentNullException("filterContext");
}

[Code]....

View 1 Replies

MVC :: OutputCache'ing With Multiple Languages?

Mar 8, 2010

I'm looking into using the OutputCache-attribute for my ASP.NET MVC website. However, my website is using resources (*.res-files) to display two different languages (based on the user's settings in a cookie and/or database setting). Is there any way I can cache actions for my two languages separately?

Setting a "VaryByHeader" isn't gonna cut it since I have lots of visitors so every second visitor has probably another language set than the visitor before him. This would cause the cached action/page to always be updated since it's a different language.

View 5 Replies

OutputCache - Cache Only If No Params In GET?

Jan 23, 2011

What parameters to use in OutputCache if you want to Cache in case of no params on a page, in other cases not caching?

View 1 Replies

MVC :: Unity Container Dependencies

Mar 1, 2011

After about 30 Minutes the whole Unity Container is away, that means that all my Dependencies rises null exceptions, because they can't get resolved.

Global.asax:

[Code]....
[Code]....

View 3 Replies

MVC :: Dependencies On Non System.Web Assemblies?

Mar 8, 2011

When looking at ASP.NET MVC 3 and WebPages (the 'simple' web application framework used by WebMatrix) I noticed that these frameworks take a dependency on assemblies and/or namespaces that do not fit the familiar naming style for ASP.NET:

- Microsoft.Web.Infrastructure
- WebMatrix.Data
- WebMatrix.WebData
- Microsoft.Web.Helpers

Most if not all assemblies/namespaces up until and including ASP.NET 4 and ASP.NET MVC 2 are called *System.Web.** Why did they do it? Is this 'a trap' or is that too cynical? Some context (from the [Mono 2.10 Release Notes][1]):

> Although ASP.NET MVC3 is open source
> and licensed under the terms of the
> MS-PL license, it takes a few
> dependencies on new libraries that are
> not open source nor are they part of
> the Microsoft.NET Framework.
>
> At this point we do not have open
> source implementations of those
> libraries, so we can not ship the full
> ASP.NET MVC3 stack with Mono.

[URL]

View 4 Replies

MVC :: Getting OutputCache When Using RenderAction And Partial View?

May 17, 2010

I am using MVC 2 and am having problems getting the OutputCache to work. My ASP.NET website has Several Views and a View Master Page. On my View Master Page I have a Menu on the left hand side displaying navigation links (implemented using JQuery).

I have implemented the Menu as a PartialView and I call this PartialView from my MasterPage using Html.RenderAction. This all works fine, my controller fetches the data from the database and the PartialView is populated.

The problem is I want to cache the Menu data since it's consistent on all pages. Yet when I add the OutputCache parameter to my Action it has no effect.

** Action **

[Code]....

** Partial View **

[Code]....

** Master Page **

[Code]....

View 11 Replies

Outputcache Doesn't Work With Routing?

Feb 4, 2010

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 ignored. Is this true or am I missing something? Can this be fixed?

I made a small test app (I uploaded it to [URL] that just contains a page, Webform1.aspx, that uses a master page and a user control. All three output the current date and time.

When I request http//localhost/OutputcacheTest/Webform1.aspx the 10 second caching works as expected, i.e. the shown time only updates every 10 seconds.

The app also defines a wildcard route that catches all requests and returns the same Webform1.aspx as a handler. So when requesting http//localhost/OutputcacheTest/myroute the same page is executed but now the caching doesn't work, i.e. the current time is shown on every request.

Note: When using the built-in development web server both scenarios work, only IIS seems to have this problem.

Does anyone have a a solution or work around for how to enable output caching in this scenario?

View 2 Replies

Outputcache - Is It Possible To Output Cache By Host Name

May 11, 2010

I've got a website that has a number of host headers. Depending on the host header, the results are different - both visually (theme'd) and data.

So lets imagine i have a website called 'Foo' - that returns search results (original, eh?).

Now, the same code runs both sites. It is physically the same server/website (using Host Headers) :-

[URL]

And the data is different for the same search result, based on the host name (ie. us results for [URL] results for [URL]

SO .. if i wish to use OutputCaching .. can this be handled / differ by the host name?

View 2 Replies

.net - OutputCache For Page Which Contains Shopping Cart?

Apr 2, 2011

I have a master page where in one ContentPlaceHolder I put my shopping cart:

<asp:ContentPlaceHolder ID="continutMeniuContulMeu" runat="server">
asp:UpdatePanel runat="server" ID="updatePanelCos" UpdateMode="Conditional">
<ContentTemplate>
<user:ShoppingCart ID="shoppingCartControl" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:ContentPlaceHolder>

View 1 Replies

Caching - View The Contents Of The OutputCache?

Feb 26, 2010

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.

View 2 Replies

Disable OutputCache On Development System?

May 7, 2010

I use OutputCache in an ASP.net MVC application. As developing with an active OutputCache is not very pleasant I want to disable the OutputCache on the Development Systems (local machines and development server).

View 1 Replies

Dependencies Not Injecting - No Method Working

Jan 11, 2010

I am trying to create an ASP.NET MVC application, using Spring.NET to inject dependencies. The application has three tiers: Controller, Service, and Data. I have defined the objects in the file "~Resourcesobjects.xml". My first object, UserAccountController, requires the injection of two Service-tier classes: UserAccountService and DepartmentService. So, the definition in objects.xml looks like this:

<object id="UserAccountController" type="App.Controllers.UserAccountController, App">
<constructor-arg index="0" ref="DepartmentService" />
<constructor-arg index="1" ref="UserAccountService" /> </object>
<object id="UserAccountService" type="App.Service.UserAccountService, App">
<property name="UserAccountDao" ref="UserAccountDao" /> </object>
<object id="UserAccountDao" type="App.Data.UserAccountDao, App" />
<object id="DepartmentService" type="App.Service.DepartmentService, App">
<property name="DepartmentDao" ref="DepartmentDao" /> </object>
<object id="DepartmentDao" type="App.Data.DepartmentDao" />

Webconfig contains this:
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
</sectionGroup> </configSections> <spring> <context>
<resource uri="~/Resources/objects.xml" /> </context> </spring>

I would prefer to use Property injection rather than constructor, but currently neither method is working.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved