Programming Microsoft ASP.NET 4 - Dino Esposito [393]
Part of a suite of products aimed at making enterprise applications more scalable, StateServer runs as a service on every machine in your server farm and stores data objects in memory while making them globally accessible across the farm within its distributed data grid. Its top selling points are the patented technology for H/A, its comprehensive API, and the outstanding StateServer console for administrative and management tasks.
For more information, visit http://www.scaleoutsoftware.com/products/scaleout-stateserver.
AlachiSoft NCache
It presents itself as the distributed version of the ASP.NET native Cache object with a ton of extra features, including a LINQ-based query language, rich eviction functionalities, event notification, and dynamic clustering. As a plus, it also has an Express version that is free for up to two cache servers running .NET 3.5. The NCache engine is also exposed as a second-level caching layer for both NHibernate and Entity Framework 4 and as an extension to the Enterprise Library Caching Block and the Cache provider mechanism of ASP.NET 4.
For more information, visit http://www.alachisoft.com/ncache.
Caching ASP.NET Pages
The concept of a Web cache is probably as old as the Web itself. Don’t worry if you’re not familiar with this term; you certainly know very well at least one kind of Web cache—the browser’s local cache.
Web sites and applications rely on the services provided by the Web server, which essentially receives requests and sends out responses. Generally speaking, a Web cache is something that sits in between a Web server and a client browser and gently takes the liberty of serving some requests without disturbing the Web server at the back end. Fundamental reasons for installing a Web cache are to reduce network traffic and to reduce latency.
The most popular type of Web cache is the browser cache. Another example of a Web cache is a proxy server that, deployed on the network, has requests and responses routed to it to cache on a larger scale than the local browser. A proxy cache is recommended for large organizations where many users might be requesting the same pages from a bunch of sites. The beneficial effects of a proxy cache expand, then, to the entire organization.
A Web cache stores representations of requested resources (such as script files, images, and style sheets), and it applies a few simple rules to determine whether it can serve the request right away or whether the resource has to be requested by the origin server. In general, all requests are subject to Web caching. At the same time, each response that serves a given resource can contain instructions for the Web cache regarding if and how to cache the resource.
Let’s see how ASP.NET pages interact with the browser cache.
ASP.NET and the Browser Cache
All Web browsers look into their cache before making a request for a given URL. ASP.NET requests are no exception. This means that if the content of the requested ASP.NET page is available on the client (and valid), often no request is made to the server. However, every time you make a change to the source ASPX file on the server, the next request for that page will get the update. If you make a change to a JavaScript file, instead, you likely will have to wait a few hours or just manually clean the local browser cache to get the update. Let’s try to understand how things work under the hood.
Typical Behavior of the Browser Cache
First and foremost, browsers won’t save any responses that explicitly prohibit the use of the cache. Furthermore, browsers won’t save any responses that come from a secure channel (HTTPS) or that require authentication.
If the requested URL doesn’t have a match in the local cache, the browser just sends the request on to the server. Otherwise, if a match is found, the browser checks whether the cached representation of the requested resource is still valid. A valid representation is a representation that has not expired. Valid representations (also referred to as fresh representations) are served