刚才看Quick Start,其中讲到页输出缓存时,说道:应用程序若要更多地控制与缓存相关的 HTTP 标头,可使用 System.Web.HttpCachePolicy 类提供的功能。下面的示例显示等效于上例中使用的页指令的代码。 
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);页指令的代码是<%@ OutputCache Duration="60" VaryByParam="none"%>
为什么我在InitializeComponent里面添加了这两句,结果发现页没有被缓存?
初学缓存,请大家不吝赐教

解决方案 »

  1.   

    <%@ OutputCache Duration="60" VaryByParam="none"%>VaryByParam表示你要缓存的内容。VaryByParam="*"
    如果设为none不能执行缓存。
      

  2.   

    up
    为什么下面两句不能起到缓存的作用
    Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
    Response.Cache.SetCacheability(HttpCacheability.Public);
      

  3.   

    up
    为什么下面两句不能起到缓存的作用
    Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));---把數據讀入緩存(字符串??)
    Response.Cache.SetCacheability(HttpCacheability.Public);