网站带后台的,用户每次启动页面都要从数据库中搜索相关的信息,当用户很多时页面打开的速度会受影响,有没有什么方法可以解决?

解决方案 »

  1.   

    听说过。问题是如何生成html啊?
      

  2.   

    设置cache的时间
    静态页面生成方式
    SqlConnection cn=DB.createCn();
    ////////////,'"+path2+"','"+fileName+"'静态页面添加
    string strSQL="insert into article (Title,Content,addTime,classID,writer,writeFrom,isImage,isHot,click,fPath,fName)"+
    "values ('"+title+"',@content,'"+mydate+"','"+class1+"','"+author+"','"+from+"','"+i+"','"+j+"','"+click+"','"+path2+"','"+fileName+"')";
    SqlCommand cmd=new SqlCommand(strSQL,cn);
    cmd.Parameters.Add(new SqlParameter("@content",SqlDbType.NText));
    cmd.Parameters["@content"].Value=this.FreeTextBox1.Text;
    SqlDataReader dr=cmd.ExecuteReader(); this.Panel1.Visible=false;
    Response.Write("添加新闻成功"); /////////////////////////////
    Encoding code=Encoding.GetEncoding("gb2312");
    StreamReader sr=null;
    StreamWriter sw=null;
    string str="";
    sr=new StreamReader(temp,code);
    str=sr.ReadToEnd();
    str=str.Replace("newstitle",this.txtTitle.Text.ToString());
    str=str.Replace("addTime",mydate2);
    str=str.Replace("from",from);
    str=str.Replace("htmlcontent",content);
    str=str.Replace("admin",author);
    sw=new StreamWriter(fullPath2+fileName,false,code);
    sw.Write(str);
    sw.Flush();
      

  3.   

    为这块数据做缓存,或者索性页面全用html
      

  4.   

    页面缓存 http://www.microsoft.com/china/MSDN/library/architecture/patterns/esp/DesPageCache.mspx
      

  5.   

    此外,asp.net2.0与SQL server2005配合,可以在数据表内容修改了的时候才刷新缓存。