页面缓存和数据缓存有什么区别,具体体现在什么地方
解决方案 »
- 从网上收集的一些源代码,电子教程和视频讲座(还有VIP视频哦)
- C#怎么将上传的Excel文件保存成csv文件
- visual studio2008怎样使第一个DIV移至网页的最顶端
- 我在线录制的FLV不能播放,有办法解决吗?
- 哪位兄弟能给我一个登陆的小例子
- 图片显示问题
- 找到DataList中<SelectedItemTemplate>中的控件
- ASP.NET 的 C#代码里有这样一个语句
- There was no endpoint listening at http://localhost:8080/Test.svc
- 怪!怪!关于用C#在Web页面上画表格的问题.(在线等待)
- ASP.NET 2.0中关于xml文件转换成html文件?
- 很简单的取xml结点属性值的问题
<%@OutputCache Duration="...以数据库为例,数据缓存是为了减少数据库访问,把数据库查询结果缓存起来。
HttpRuntime.Cache.Insert(....);
HttpContext.Cache["key"] = ...还有SqlDataSource/ObjectDataSource也支持数据缓存。..
<%@ OutputCache Duration="60" VaryByParam="none" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
以上文件的CS代码如下所示:using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Text = DateTime.Now.ToLongTimeString();
}
}
相信大家都看得懂,以上代码的作用是将当前时间显示在网页上。如果刷新该页面,当前时间应该会改变的。
但是,因为在aspx页面上使用了
<%@ OutputCache Duration="60" VaryByParam="none" %>其中,OutputCache就是输出缓存,Duration为缓存时间60秒,VaryByParam说明该缓存不受post或get参数的变化而影响。因此,在打开该网页时,在60之内,无论怎么刷新,网页上的时间都不会改变的,只有60秒之后刷新才会改变。