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ÖÐÒ³Ãæ´«Öµ¹²ÓÐÕâô¼¸ÖÖ·½Ê½£º
1¡¢±íµ¥Ìá½»£¬
<form action= "target.aspx" method = "post" name = "form1">
<input name = "param1" value = "1111"/>
<input name = "param2" value = "2222"/>
</form>
....
for ......
Ò»¡¢Ð§¹û¼ò½é
¡¡¡¡µ±µã»÷Ò»¼¶À¸Ä¿Ê±£¨ÈçÊ×Ò³£©£¬±»µã»÷µÄÒ»¼¶À¸Ä¿µÄµ¥Ôª¸ñ±³¾°É«·¢Éú±äÉ«£¬Èç¹û¸ÃÒ»¼¶À¸Ä¿ÏÂÓжþ¼¶À¸Ä¿£¬Ôò»áÔÚÏÂÒ»ÐÐÏÔʾ³öÀ´£¬·ñÔò¶þ¼¶À¸Ä¿ÕâÒ»Ðв»»áÏÔʾÈκζ«Î÷£¬µ«»áÕ¼Ò»¶¨µÄ¸ß¶È¡£µ±µã»÷¶þ¼¶À¸Ä¿Ê±£¬ÆäËùÊôµÄÒ»¼¶À¸Ä¿µ¥Ôª¸ñ±³¾°É«·¢Éú±ä»¯£¬Í¬Ê±±»µã»÷µÄ¶þ¼¶À¸Ä¿Ãû³Æ»á¼Ó´Ö£¬²¢ÔÚǰ·½¼ÓÒ»¸ö“¡ ......
Ò»¡¢»ñÈ¡µ±Ç°ÎļþµÄ·¾¶
1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
»ñȡģ¿éµÄÍêÕû·¾¶£¬°üÀ¨ÎļþÃû¡£
2. System.Environment.CurrentDirectory
»ñÈ¡ºÍÉèÖõ±Ç°Ä¿Â¼(¸Ã½ø³Ì´ÓÖÐÆô¶¯µÄĿ¼)µÄÍêÈ«ÏÞ¶¨Ä¿Â¼¡£ ......
//»ñÈ¡ÈÕÆÚ+ʱ¼ä
DateTime.Now.ToString(); // 2008-9-4 20:02:10
DateTime.Now.ToLocalTime().ToString(); // 2008-9-4 20:12:12
//»ñÈ¡ÈÕÆÚ
DateTime.Now.ToLongDateString().ToString(); // 2008Äê9ÔÂ4ÈÕ
D ......