ASP.NET Cache
1. INTRODUCTION
´óÁ¿µÄÍøÕ¾Ò³ÃæÊDzÉÓö¯Ì¬µÄ·½Ê½£¬¸ù¾ÝÓû§Ìá½»µÄ²»Í¬ÇëÇó´´½¨Éú³ÉÒ³Ãæ¡£ÕýÈçÎÒÃÇËùÖªµÄ£¬¶¯Ì¬Ò³ÃæÓÐÖúÓÚ¸ù
¾ÝÓû§ÒªÇóÀ´Ìṩ¶¨ÖƵĶ¯Ì¬ÄÚÈÝ¡£¶¯Ì¬Ò³ÃæÒ²ÀûÓÚ»ñÈ¡ÔÚÊý¾Ý¿âÖÐÿʱÿ¿Ì¸üеÄ×ÊÁÏ¡£È±µãÊÇΪÿ¸öÓû§ÇëÇóÉú³ÉͬһҳÃæÔö¼ÓÁËϵͳ¿ªÏú¡£
ASP.NET
ÌṩÁË»º´æ¼¼ÊõÓÐÖúÓÚÎÒÃÇ×î´ó³Ì¶ÈµØ½â¾öÕâ¸öÎÊÌâ¡£ËüÄÜ»º´æÊä³öµÄÒ³Ã棬±£´æÔÚ´æ´¢Æ÷µ±ÖУ¬»º´æÓû§ÇëÇóµÄÄÚÈÝ¡£»º´æµÄÌصã¿ÉÒÔ¸ù¾Ý²»Í¬·½Ê½À´¶¨ÖƵġ£
±¾ÎÄÖ÷Òª½éÉÜASP.NETµÄ»º´æ¼¼Êõ¡£½éÉÜÆäʹÓ÷½·¨£¬ÒÔ¼°¿Í»§¶Ë»º´æ´æÔÚµÄÎÊÌâ¡£
2. ASP.NET CACHE
ȼ
´æÊÇ°ÑÓ¦ÓóÌÐòÖÐÐèҪƵ·±¡¢¿ìËÙ·ÃÎʵÄÊý¾Ý±£´æÔÚÄÚ´æÖеıà³Ì¼¼Êõ¡£ASP.NETÌṩÈýÖÖÖ÷ÒªÐÎʽµÄ»º´æ£ºÒ³Ã漶Êä³ö»º´æ¡¢Óû§¿Ø¼þ¼¶Êä³ö»º´æ£¨»ò³ÆΪ
Ƭ¶Î»º´æ£©ºÍ»º´æAPI¡£Êä³ö»º´æºÍƬ¶Î»º´æµÄÓŵãÊǷdz£Ò×ÓÚʵÏÖ£¬ÔÚ´ó¶àÊýÇé¿öÏ£¬Ê¹ÓÃÕâÁ½ÖÖ»º´æ¾Í×ã¹»ÁË¡£¶ø»º´æAPIÔòÌṩÁ˶îÍâµÄÁé»îÐÔ£¨Êµ¼ÊÉÏ
ÊÇÏ൱´óµÄÁé»îÐÔ£©£¬¿ÉÓÃÓÚÔÚÓ¦ÓóÌÐòµÄÿһ²ãÀûÓûº´æ¡£±¾ÎÄÖ»½éÉÜÒ³Ã漶»º´æºÍÓû§¿Ø¼þ¼¶»º´æ¡£
2.1. Page Caching
×÷
Ϊ×î¼òµ¥µÄ»º´æÐÎʽ£¬Êä³ö»º´æÖ»ÊÇÔÚÄÚ´æÖб£ÁôΪÏìÓ¦ÇëÇó¶ø·¢Ë굀 HTML
µÄ¸±±¾¡£ÆäºóÔÙÓÐÇëÇóʱ½«Ìṩ»º´æµÄÊä³ö£¬Ö±µ½»º´æµ½ÆÚ£¬ÕâÑù£¬ÐÔÄÜÓпÉÄܵõ½ºÜ´óµÄÌá¸ß£¨È¡¾öÓÚÐèÒª¶àÉÙ¿ªÏúÀ´´´½¨ÔʼҳÃæÊä³ö -
·¢ËÍ»º´æµÄÊä³ö×ÜÊǺܿ죬²¢ÇұȽÏÎȶ¨£©¡£
ҪʵÏÖÒ³ÃæÊä³ö»º´æ£¬Ö»Òª½«Ò»Ìõ OutputCache Ö¸ÁîÌí¼Óµ½Ò³Ãæ¼´¿É£º
£¼%@
OutputCache Duration="60" VaryByParam="*" %£¾
ÈçͬÆäËûÒ³ÃæÖ¸ÁîÒ»Ñù£¬¸ÃÖ¸ÁîÓ¦¸Ã³öÏÖÔÚ
ASPXÒ³ÃæµÄ¶¥²¿£¬¼´ÔÚÈκÎÊä³ö֮ǰ¡£ËüÖ§³ÖÎå¸öÊôÐÔ£¨»ò²ÎÊý£©£¬ÆäÖÐÁ½¸öÊDZØÐèµÄ¡£
Duration£º±ØÐèÊôÐÔ¡£Ò³ÃæÓ¦¸Ã±»»º´æµÄʱ¼ä£¬ÒÔÃëΪµ¥Î»¡£±ØÐëÊÇÕýÕûÊý¡£
Location£ºÖ¸¶¨Ó¦¸Ã¶ÔÊä³ö½øÐлº´æµÄλÖá£Èç¹ûÒªÖ¸¶¨¸Ã²ÎÊý£¬Ôò±ØÐëÊÇÏÂÁÐÑ¡ÏîÖ®Ò»£ºAny¡¢Client¡¢Downstream¡¢None¡¢
Server »ò ServerAndClient¡£
VaryByParam£º±ØÐèÊôÐÔ¡£Request
ÖбäÁ¿µÄÃû³Æ£¬ÕâЩ±äÁ¿ÃûÓ¦¸Ã²úÉúµ¥¶ÀµÄ»º´æÌõÄ¿¡£"none" ±íʾûÓб䶯¡£"*" ¿ÉÓÃÓÚΪÿ¸ö²»Í¬µÄ±äÁ¿Êý×é´´½¨ÐµĻº´æÌõÄ¿¡£±äÁ¿Ö®¼äÓÃ
";&q
Ïà¹ØÎĵµ£º
ÔÚasp.netÀïÔõô¸ú¾ÝÓû§È¨ÏÞÀ´Éú³ÉÊ÷Ðβ˵¥
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
......
Asp.NetÖÐÓÐÒ»Ì×ÓëÓû§Ïà¹ØÁªµÄÊôÐÔÉèÖ㬿ÉÒÔͨ¹ýÔÚWebConfigÀïÅäÖÃÀ´Ö±½ÓʹÓã¬ËûµÄ×÷ÓÃΪ
´æ´¢ºÍʹÓÃΨһÓëÓû§¶ÔÓ¦µÄÐÅÏ¢
Õ¹ÏÖ¸öÈË»¯°æ±¾µÄWebÓ¦ÓóÌÐò
Óû§µÄΨһÉí·Ý±êʶÔÚÔٴηÃÎÊʱʶ±ðÓû§
Asp.Net ProfileÌṩµÄ¸úÓû§Ïà¹ØµÄÀàÐͶ¼ÊÇÇ¿ÀàÐÍ
Ê×ÏÈÉú³ÉÊý¾Ý¿â½Å±¾£¬Ê¹ÓÃVisual Studio 2005 ÃüÁîÌáʾ£¬ÊäÈëÃü ......
ASP.NET 4µÄWeb Formsµ±ÖУ¬×îÁîÈ˼¤É͵ģ¬ÔòĪ¹ýÓÚÊÇURL Routing»úÖƵÄÈ«ÃæÖ§³Ö¡£¹ýÈ¥ÔÚASP.NET 3.5 SP1µ±ÖУ¬Web Forms»ò¶à»òÉپͿªÊ¼Ö§³ÖURL Routing»úÖÆ£¬ËüÈÃÎÒÃÇÔÚÍøÖ·µÄ³ÊÏÖÒÔ¼°Ê¹ÓÃÉϸü¼ÓµÄÓе¯ÐÔ¡£
¹ýÈ¥ÎÒÃÇÔÚASP.NETµ±ÖУ¬Ï°¹ßÓÚµ×ÏÂÕâÑùµÄÍøÖ·³ÊÏÖ·½Ê½£º
http://myWebSite/EditProduct.aspx?Id=1
µ«×î½ü¼¸ÄêR ......
ÔÚÒ»¸öÏîÄ¿¿ª·¢ÖУ¬showdialogµ¯³ö¶Ô»°¿òʱ£¬ÎÒ֮ǰÐ޸ĹýµÄÊý¾Ý²»»á¼°Ê±¸üУ¡
ʹÓýûÓÃURL»º´æµÄ·½·¨,½â¾öÕâ¸öÎÊÌâ
ÔÚasp.netÒ³ÃæµÄºǫ́
if (!IsPostBack)
{
Response.Buffer = true;
......
ASP.NETĸ°åµÄÓ¦Óã¨×ª£©
2009Äê11ÔÂ30ÈÕ ÐÇÆÚÒ» ÏÂÎç 01:11
ĸ°æÒ³ÊÇVS2005ÖÐÐÂÒýÈëµÄÒ»¸ö¸ÅÄËüºÜºÃµØʵÏÖ½çÃæÉè¼ÆµÄÄ£¿é»¯£¬²¢ÇÒʵÏÖʵÏÖÁË´úÂëµÄÖØÓá£Ëü¾ÍÏñ»éÉ´Ó°Â¥ÖеĻéÉ´Ä£°å£¬Í¬Ò»¸ö»éÉ´Ä£°å¿ÉÒÔ¸ø²»Í¬µÄÐÂÈËÓã¬Ö»Òª°ÑËûÃǵÄÕÕƬÌùÔÚÒÑÓеĻéÉ´Ä£°å¾Í¿ÉÒÔÐγÉÒ»ÕÅƯÁÁµÄ»éÉ´ÕÕƬ£¬ÕâÑù¿ÉÒÔ´ó´ó¼ò»¯»éÉ´ÒÕÊõÕ ......