Adsence750x90

Sunday, February 15, 2009

Page Caching in ASP.Net - enable and disable client cache

How to Enable Page output caching in ASP.NET?

ASP.NET provides easier methods to control caching. You can use the @ OutputCache directive to control page output caching in ASP.NET. Use the HttpCachePolicy class to store arbitrary objects, such as datasets, to server memory. You can store the cache in applications such as the client browser, the proxy server, and Microsoft Internet Information Services (IIS). By using the Cache-Control HTTP Header, you can control caching.

Some datas are not requried to reload all time when clint attempting to server. we can save ouput page cache in Client side.



method 1

Take ISS (Inertner Information Service) form machine. select site then take properties then
select HTTP Headers Enable content Exparation. this Set your sites output cache properties



Method 2

we Can add Programmatic
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Declarative method
<%@ OutputCache Duration="60" VaryByParam="None" %>
Turn off Caching
Response.Cache.SetCacheability(HttpCacheability.NoCache);

No comments: