Architecture :: Distributed Caching / Keeping Cache In Sync Between Multiple Webservers Or Even Better Farm Cache Management To Another Server?

Feb 26, 2010

I've got a web application that runs of a state server. It looks like soon it may need to distributed and there will be two web servers behind a load balancer.

This works great for session state but my next challenge is Cache

My application leverages heavily of cache. I understand ASP.Net 4.0 will be offering more here but nothing much has been said about the how too.

There are two challenges that I face

1). Each webserver will have its own copy of cache whereas it would be more efficient to put this to a third server the same as session state is put to state server.

2). The real challenge is keeping cache in sync if a simple dataset derived from the database is changed my code dumps that cache item and reloads the cache. That's all well on one webserver but webserver number two wont know to drop that particular cache item and reload it. This could cause some unexpected problems in the application.

For scenario number 2 I could attempt to do some smart coding so server number two knows to dump the cache and reload it.

My guess is someone else has already been here before and there's probably a better implementation approach rather than writing extra code.

Does anyone know how I could achieve the goal of keeping Cache in sync between multiple webservers or even better farm Cache management to another server?

View 2 Replies

Similar Messages:

C# - Implement System.Web.Caching.Cache Object In A Controller To Cache Specific Query?

Mar 29, 2010

Is it correct to implement my caching object like this in my controller :


And I Use it like this :


View 1 Replies

State Management :: Where Is The System.Web.Caching.Cache Actually Stored

Nov 25, 2010

I am using this to store my user information for authentication. I'd like to know where this is actually being stored? I know that people suggest to store the Session state in SQL. Is this necessary for the Cache as well?

View 4 Replies

Architecture :: Cache The Full List Of Objects In Http Cache On The Service Tier And Page In Memory?

Feb 25, 2011

We have a wfc layer that wraps the business classes and database access and use a client that lives on the database layer. Amongst our group we are attempting to form standards. Some want to have the client call the web method and pass the page they are requesting and the page size. Pass that to the database and then page in SQL Server use RowNum.Some want to cache the full list of objects in http cache on the service tier and page in memory. They concern here is memory use on the server.

Which would be best for a medium number of users with potentially large number of records to manage (say 30K) Is it better to cache them all in memory and work from there or page at the database as the application scales?

View 1 Replies

Forms Data Controls :: Caching DataTable - Create/cache Multiple DataTables?

Jul 23, 2010

Among the many aspects of that I haven't focused my development on yet is caching. I have a perfect application for it now, I think, with a GridView that sits inside a repeater, and is bound in the Repeater ItemDataBound event. The contents of the GridView will remain static for each Repeater data item for each Client. The nature of the data in the GridView is that it can change from day to day per Client, but wouldn't need to be refreshed more frequently than that. The Page istelf only deals with one at a time Client based on a QueryStringParameter. My questions are a) how do I cache the DataTable so that a call to the DataBase isn't made each time Repeater item is bound and b) can I create/cache multiple DataTables (one for each Client) and let them live for day, checking for existence before calling the SQL stored procedure to regenerate the data?

My DataTable method: [Code]....

View 2 Replies

Architecture :: Handle BL Cache For Multiple Web Applications?

Mar 27, 2010

I recently received a project that contains multiple web applications with no MVC structure. For starters I've created a library (DLL) that will contain the main Business Logic. The problem is with Caching - If I use the current web context cache object than I might end up with duplicate caching (as the web context will be different for every application).

I'm currently thinking about implementing a simple caching mechanism with a singleton pattern that will allow the different web sites (aka different application domains) to share their "caching wisdom". I'd like to know what is the best way to solve this problem.

View 3 Replies

Caching - What Techniques Should Be Used To Handle Objects In Cache To Prevent Problems From Multiple Worker Threads Access

Sep 8, 2010

since contains multiple threads that are executing at the same if 2 threads access an object (simple or complex) that i got from the the httpcontext Cache.can't this lead to state problems on that object if these 2 theads tried to modify/read it at the same time?so what kind of precautions should i implement?for example i am thinking maybe locking the object while working with it? (wont this cause performance problems?)or maybe when i retrieve some object from the cache i should create a copy from it?
or maybe i dont need to worry about this issue at all?

View 2 Replies

Custom Server Controls :: How To Programmatically Cache A Server Control And Add A Cache Dependency?

Feb 11, 2011

I have a server control that I developed which generates navigation based on a third party CMS API. Currently I am caching this control using the PartialCaching attribute. The CMS uses cache key dependencies to invalidate the cache when a user makes an edit, however in the case of my server control it does not get invalidated and the updated navigation will not show up until the cache expiration set by the PartialCaching attribute.Here is my two part question:

What is the proper way to programmatically cache a server control, without using the PartialCaching attribute, and adding a cache key dependency?

Is it possible to continue to use the PartialCaching attribute and add a cache key dependency?

View 2 Replies

MVC :: How To Cache MVC Page - Donut Caching With .NET

Oct 1, 2010

[OutputCache (Duration=20, VaryByParam="None" )]
public ActionResult display()

This code cache whole page.But, my site has user infomation on top like this The user info "Signed as userid | Edit Profile | ..." section should be changed when user sign in/out. But rest of the page is always same and it's good to Cache.

If the above code is used, the user info on top also cached and give wrong info to user.

View 11 Replies

Caching - How To Cache A List Of Objects

Jan 23, 2010

I have a List of objects in an page. when the page loads in the browser for the first time, I fetch data from the database, create objects with those data and populate the list. All these are done inside the page load event handler. Now when the page is posted back to the page, the previous list is gone, since the variables were all freed.

How can I cache that List, so that when this page is posted back, all my objects are available?

View 5 Replies

C# - Distributed Critical Section In Web-farm?

Mar 18, 2011

I have about 50 web-sites, load-balanced across 5 web-servers. They all use Enterprise Library Caching, and access the same Caching database. The items in the Caching database are refreshed every few hours, using an ICacheItemRefreshAction implementation.I want to guarantee that only one web-site ever refreshes the cache, by putting the refresh code in a critical section. If the web-sites were running in a single app-pool on a single server, I could use a lock()If the web-sites were running in separate app-pools on a single server, I could use a Mutex.However, these will not ensure the critical section across multiple web-servers.Currently, I am creating a new key in the caching database to act as a mutex. This will generally work, but I can see a slim chance that 2 processes could enter the critical section.

public class TakeLongTimeToRefresh : ICacheItemRefreshAction
#region ICacheItemRefreshAction Members


View 2 Replies

State Management :: SQL Server Based Cache Dependency Without Data Source Control?

May 29, 2010

I want to use SQL Server based Cache dependency without data source control.How can I do it?I am binding data to grid through code.

View 5 Replies

C# - Caching Through HttpContext.Current.Cache Or Just A Static?

Mar 28, 2011

Last night I wrote up my first IHttpModule to do some request processing. I'm using a regular expression to inspect the raw url. The IHttpModule will be called on every request, so it seems reasonable to do some sort of caching of the regular expression object to prevent creation of it on every request.

Now my question... what is better: use the HttpContext.Current.Cache to store the instantiated object or to use a private static Regex in my module?I'm looking forward to the reasons why. Just to clarify: the regex will never change and thus always be the same thing.

View 3 Replies

Caching - How To Hold Current Date In Cache

Jul 28, 2010

I am building a web application using (c#) and lingtosql. When I perform update operations on my db I update my classes. I use gridview to bind to update information. When I relay solely on the database the page's take very long to load. When I relay solely on the cache, I have old data. What workarounds do I have for have asynchronous cache updating, yet not overload the database with endless requests (I'd like to update the cache only if there has been a change in the database itself, and perform the update operation asynchronously).

View 1 Replies

Caching - What Is The Default Serialization Used By The HttpRuntime.Cache

Jan 29, 2010

what the default serialization used by the HttpRuntime.Cache is? Is it Binary, XML, something else?

I am populating a generic List with multiple objects of the same custom type. The custom type is a POCO, there is nothing special about it. All of its properties are public with { get; set; }, it is public, it has no inheritance, it has no interfaces. In fact it is much less complicated than many other objects which we are caching which work without issue. I have tried adding the [Serializable] attribute to the custom class and it has no effect.

I add the list to the cache with a unique key. The list has been verified as populated before it is inserted into the cache, the objects in the list have been verified as populated as well. But when the list is pulled back out of the cache it is an empty list (NOT NULL), it simply has no items in it. This means that the list is being added to the cache and is retrievable but for some reason the cache is having issues serializing the objects in the list.

I just find this freaky weird since I have another list of custom objects which are much more complicated (consisting of Inheritance, Interfaces, and also containing Properties which are generic lists of other complex objects) and the caching of those lists work without issue.

Both the working and non-working list are being managed in C# classes outside of the user controls which consume the cached data. Both of these cache handling classes call the exact same Cache Manager class singleton instance which wraps the HttpRuntime.Cache to provide typed methods for pull and pushing objects into the cache.

Here is the class


View 2 Replies

Caching - Cache Render Of Calendar Control?

Sep 8, 2010

We display an ASP.NET calendar control and update the color and if the day is enabled with the DayRender event. This process is a bit slow so I'm trying to map out a strategy to cache the results of the all the DayRenders. Basically take a snapshot of the calendar and cache it for X minutes. Where would I hook into the page/control workflow to accomplish this goal?

View 1 Replies

Caching - Controlling Output Cache Memory Usage?

May 17, 2010

I would like to use output caching with WCF Data Services and although there's nothing specifically built in to support caching, there is an OnStartProcessingRequest method that allows me to hook in and set the cacheability of the request using normal ASP.NET mechanisms.

But I am worried about the worker process getting recycled due to excessive memory consumption if large responses are cached. Is there a way to specify an upper limit for the ASP.NET output cache so that if this limit is exceeded, items in the cache will be discarded?

I've seen the caching configuration settings but I get the impression from the documentation that this is for explicit caching via the Cache object since there is a separate outputCacheSettings which has no memory-related attributes.

Here's a code snippet from Scott Hanselman's post that shows how I'm setting the cacheability of the request.


View 1 Replies

System.Web.Caching.Cache Doesn't Seem To Refresh Itself On Time

Jan 27, 2011

I am using System.Web.Caching.Cache in an assembly used by my website.

I have set some key expiration (absolute expiration) to be 10 seconds (just for debugging).

I have also set a callback upon key removal.

The problem is that I see that the cache is getting refreshed after something like 20 seconds and not 10.

I am using HttpRuntime.Cache for this.

I would like to show a code sample, which can shed more light:


What could be the problem ?

View 2 Replies

How To Setup Caching For A Page In .NET And Give It A Cache Key Dependency

Feb 15, 2011

How do I setup caching for a Page in ASP.NET and give it a cache key dependency? I am familiar how to do this with a UserControl, I set a Partial Caching attribute and then set

this.CachePolicy = new CacheDependency(..)

How would I do this for a Page? It does not have a CachePolicy object,

View 1 Replies

Caching User Control And Clearing That Cache Programmatically?

Jul 13, 2010

I'm trying to cache user controls and on some pages i want to cache single objects. There are multiple ways of implementing caching, and my head is breaking over it.

The way I see the caching options now:

You have the PartialCaching option which is set to cache the control for 30 minutes, and after that it clears itself... You have the varyByParam to identity the page by its querystring paramaters... or other vary options

But i just cant find an appropriate way to add caching to a control, and be able to clear the caching programmatically when i update one of the objects used in the control from the backend.

You can do HttpContext.Current.Cache.Insert(), which accepts a key on which you can destroy the caching item later by using remove... This can save objects in cache but can you use options like varyByParam?

My questions are burnt down to two:

Is there a way to clear the caching on specific user controls from the code? If yes, can this be done according to the varyby options? How would the object caching respond to logged in users or anonymous users using Insert()?

EDIT: I'm caching multiple things.... And I'm really flabbergasted in which choice to make referring to caching. Can the Cache.Insert be varied by Parameters?

The main problem is peopling editing things from the backend, which needs to trigger an event that reinstantiates or clears all caching items referring that object.

View 2 Replies

C# - Caching W/file Dependency: Static Var Vs. AspNet Cache Vs. Memcached

Sep 29, 2010

TL;DR: Which is likely faster: accessing static local variable, accessing variable stored in HttpRuntime.Cache, or accessing variable stored in memcached?At work, we get about 200,000 page views/day. On our homepage, we display a promotion. This promotion is different for different users, based on their country of origin and language.

All the different promotions are defined in an XML file on each web server. We have 12 web servers all serving the same site with the same XML file. There are about 50 different promotion combinations based on country/language. We imagine we'll never have more than 200 or so (if ever) promotions (combinations) total.

The XML file may be changed at any time, out of release cycle. When it's changed, the new definitions of promotions should immediately change on the live site. Implementing the functionality for this requirement is the responsibility of another developer and I.

Originally, I wrote the code so that the contents of the XML file were parsed and then stored in a static member of a class. A FileSystemWatcher monitored changes to the file, and whenever the file was changed, the XML would be reloaded/reparsed and the static member would be updated with the new contents. Seemed like a solid, simple solution to keeping the in-memory dictionary of promotions current with the XML file. (Each server doing this indepedently with its local copy of the XML file; all XML files are the same and change at the same time.)

The other developer I was working holds a Sr. position and decided that this was no good. Instead, we should store all the promotions in each server's HttpContext.Current.Cache with a CacheDependency file dependency that automatically monitored file changes, expunging the cached promotions when the file changed. While I liked that we no longer had to use a FileSystemWatcher, I worried a little that grabbing the promotions from the volitile cache instead of a static class member would be less performant.

(Care to comment on this concern? I already gave up trying to advocate not switching to HttpRuntime.Cache.)

Later, after we began using HttpRuntime.Cache, we adopted memcached with Enyim as our .NET interface for other business problems (e.g. search results). When we did that, this Sr. Developer decided we should be using memcached instead of the HttpRuntime (HttpContext) Cache for storing promotions. Higher-ups said "yeah, sounds good", and gave him a dedicated server with memcached just for these promotions. Now he's currently implementing the changes to use memcached instead.

I'm skeptical that this is a good decision. Instead of staying in-process and grabbing this promotion data from the HttpRuntime.Cache, we're now opening a socket to a network memcached server and transmitting its value to our web server.This has to be less performant, right? Even if the cache is memcached. (I haven't had the chance to compile any performance metrics yet.)On top of that, he's going to have to engineer his own file dependency solution over memcached since it doesn't provide such a facility.

Wouldn't my original design be best? Does this strike you as overengineering? Is HttpRuntime.Cache caching or memcached caching even necessary?

View 2 Replies

404 Error When Caching .aspx Pages With HTML5 Cache Manifest - How To Fix It

Feb 28, 2011

Has anyone been able to cache .aspx pages using the HTML cache manifest? I am porting an html application over to (and mvc2) and I get a 404 error when trying to cache any *.aspx page. Other files still cache normally (.js, .css, etc). I have changed permissions, handlers, and file names and still no luck. Below is the actual manifest:

# This file was generated at 2/28/2011 4:03 PM

View 1 Replies

C# - System.Runtime.Caching (ObjectCache) - How To Inspect Cache Policies

Feb 8, 2011

I'm making use of the new .NET 4.0 Caching namespace: System.Runtime.Caching.Now, i'm just doing some prototype/fiddling with the new API, in order to work out the best fit for the real app.In line with that, i'm trying to create a page (ASP.NET MVC) that basically dumps out everything in the cache, particularly the following info:

Cache Key
Cache Object
Cache Policy (expiry date, etc)
Cache Dependencies (if any)

However, i can't seem to get anything except the key/object.Here's the code i'm currently playing with:

public ActionResult Index()
var cache = MemoryCache.Default;


View 1 Replies

Web Forms :: Fragment Caching User Controls And Cache Invalidation?

Apr 8, 2010

In our .aspx pages we have user controls each control has a Sql query to fetch data. The caching mechanism to be followed says that fragment cache all the user controls and invalidate the cache based on the respective queries of the user control.How to proceed to add a query dependency to fragment cached user control?

View 1 Replies

New-Cache Parameters For AppFabric Cache When Storing.NET Session State

Jul 28, 2010

What are the "optimal" parameters for creating an AppFabric cache when you will be storing session state in the cache? MSDN Cache-Related Commands

Powershell command line:

New-Cache [-CacheName] <String> [-Eviction <String>] [-Expirable <String>] [-Force [<SwitchParameter>]] [-NotificationsEnabled <String>] [-Secondaries <Int32>] [-TimeToLive <Int64>]


Since I don't want my sessions to be removed unless the session has been abandoned either via code or Session Timeout...For eviction, I would think "None" and for expireable, I would think False.I have tested and calling Session.Abandon does remove the object from the cache. I have also tested to see if by extending my session, the session object in cache is also extended. This does seem to work the "correct" way.

View 1 Replies

Copyrights 2005-15, All rights reserved