400 186 1886
OA教程
經驗分享
安裝指引
工作流
ERP教程
經驗分享
銷售管理
采購管理
生產管理
倉庫管理
工程管理
品質管理
財務管理
模切知識交流
經驗分享
技術文檔
PMS教程
CRM教程
開發文檔
其他文檔
MIS教程
MAS教程
EBR教程
企業管理
微信好文
讀書沙龍
無題
網站管理員
微軟建議的ASP性能優化28條守則(2)
當前位置:
點晴教程
→
知識管理交流
→
『 技術文檔交流 』
admin
2010年7月3日 13:25
本文熱度 6645
[p][b]技巧 21:啟用瀏覽器和代理緩存[/b][/p]
[p] 在默認情況下,asp 禁止在瀏覽器和代理中進行緩存。這是有意義的,因為就實質而言 asp 頁面是動態的,上面有隨時間不斷變化的潛在信息。如果頁面不要求在每個視圖上進行刷新,您應啟用瀏覽器和代理緩存。這可使瀏覽器和代理在一定的時間內使用頁面的“緩存”副本,您可以控制時間的長短。緩存可以大大減輕服務器上的負載,縮短用戶的等待時間。[/p]
[p] 哪一種動態頁面可作為要緩存的頁面呢?下面舉一些例子:[/p]
[p] 天氣預報頁面,在此頁面上,每隔 5 分鐘更新一次天氣預報。 [br] 列出新聞條目或新聞稿的主頁,它一天更新兩次。 [br] 共同基金業績列表,在此列表中,基本統計信息每隔幾小時更新一次。 [br] 注意,在使用瀏覽器或代理緩存的情況下,web 服務器上記錄的訪問次數減少了。如果您想準確地測量所有頁面視圖或張帖公布,您就不希望使用瀏覽器和代理緩存。[/p]
[p] 瀏覽器緩存由 http“過期”報頭控制,該報頭由 web 服務器發送給瀏覽器。asp 提供兩個簡單的機制發送此報頭。要設置頁面使其過多少分鐘后到期,則應設置 response.expires 屬性。下面的例子告訴瀏覽器內容在 10 分鐘內過期:[/p]
[p]<% response.expires = 10 %>[/p]
[p] 若將 response.expires 設置為負數或 0,則禁用緩存。一定要使用大的負數,如 -1000(略多于一天),以避免服務器和瀏覽器時鐘之間的不匹配。第二個屬性 response.expiresabsolute 將使您設置內容過期的具體時間:[/p]
[p]<% response.expiresabsolute = #may 31,2001 13:30:15# %>[/p]
[p] 您可以不使用 response 對象設置過期時間,而將
標記寫進 html,通常寫在 html 文件的 部分。一些瀏覽器將遵照此指令,而代理則不然。[/p]
[p]
[/p]
[p] 最后,您可以使用 response.cachecontrol 屬性,指示其內容是否可以讓 http 代理緩存。若將此屬性設置為“public”,代理就可以緩存此內容。[/p]
[p]<% response.cachecontrol = ?public? %>[/p]
[p] 在默認情況下,此屬性被設置為“private”。注意,對于顯示某用戶特定數據的頁面,不應啟用代理緩存,因為代理可能給用戶提供屬于其他用戶的頁面。[/p]
[p]#p#[/p]
[p][b]技巧 22:盡可能使用 server.transfer 代替 response.redirect[/b][/p]
[p] response.redirect 讓瀏覽器請求另一個頁面。此函數常用來將用戶重定向到一個登錄或錯誤頁面。因為重定向強制請求新頁面,結果是瀏覽器必須到 web 服務器往返兩次,且 web 服務器必須多處理一個請求。iis 5.0 引入了一個新的函數 server.transfer,它將執行轉移到同一臺服務器上的另一個 asp 頁。這樣就避免多余的瀏覽器-web-服務器的往返,從而改善了總體系統性能以及縮短了用戶的響應時間。檢查“重定向”中的“新的方向”,上面應該是 server.transfer 和 server.execute。[/p]
[p] 另請參見 leveraging asp in iis 5.0,了解 iis 5.0 和 asp 3.0 新功能的完整列表。[/p]
[p][b]技巧 23:在目錄 url 中使用后斜杠[/b][/p]
[p] 一個相關的技巧是確保在指向目錄的 url 中使用后斜杠 (/)。如果您省略了后斜杠,瀏覽器就會向服務器發出請求,只是為了告訴服務器,它在請求目錄。瀏覽器就會發出第二個請求,將斜杠附加到 url 后面,只有此后,服務器才能以該目錄的默認文檔或目錄列表(如果沒有默認文檔且啟用了目錄瀏覽的話)響應。附加斜杠可省去第一個、無用的住返。為便于用戶閱讀,可以省略顯示名稱中的后斜杠。[/p]
[p] 例如,寫:[/p]
[p]
http://msdn.microsoft.com/workshop
[/p]
[p] 這也適用于指向 web 站點上主頁的 url:使用下面的:
,而不使用
。[/p]
[p][b]技巧 24:避免使用服務器變量[/b][/p]
[p] 訪問服務器變量會使 web 站點向服務器發出一個特殊請求,并收集所有服務器變量,而不只是您請求的那個變量。這種情況類似于,在發霉的閣樓上,在一個文件夾中查找某個文件。當您想要找那個文件時,您必須去閣樓上,先找到文件夾,然后才能找到這份文件。當您請求服務器變量時,發生的情況是一樣的 - 您第一次請求服務器變量時,就會使性能受到影響。后面的對其它服務器變量的請求,則不會對性能產生影響。[/p]
[p] 決不要訪問非限定的 request 對象(例如,request("data"))。對于不在 request.cookies、request.form、request.querystring 或 request.clientcertificate 中的項目,則隱式調用 request.servervariables。request.servervariables 集合比其它集合慢得多。[/p]
[p][b]技巧 25:升級到最新和最出色的[/b][/p]
[p] 系統組件是恒定的,我們建議您將它們升級到最新和最好的配置。最好升級到 windows 2000(因此,也應升級到 iis 5.0、ado 2.5、msxml 2.5、internet explorer 5.0、vbscript 5.1 和 jscript 5.1)。在多處理器計算機上,實施 iis 5.0 和 ado 2.5 可顯著改善性能。在 windows 2000 下,asp 可以很好地擴展到四個處理器或更多,而在 iis 4.0 下,asp 的擴展性不能超出兩個處理器。在應用程序中使用的腳本代碼和 ado 越多,升級到 windows 2000 之后,性能的改善就會越多。[/p]
[p] 如果目前還不能升級到 windows 2000,您可以升級到 sql server、ado、vbscript 和 jscript、msxml、internet explorer 和 nt 4 service packs 的最新版本。它們均可提高性能和可靠性。[/p]
[p][b]技巧 26:優化 web 服務器[/b][/p]
[p] 有多種 iis 優化參數可以改善站點性能。例如,對于 iis 4.0,我們常常發現,增加 asp processorthreadmax 參數(參見 iis 文檔)可以顯著改善性能,特別是在傾向于等待后端資源(如數據庫)或其它中間產品(如屏幕刷)的站點上。在 iis 5.0 中,您可能發現啟用 asp thread gating 比查找一個 aspprocessorthreadmax 最佳設置效率更高,這一點現在已為大家所熟知。[/p]
[p] 有關較好的參考資料,參見下面的優化 iis。[/p]
[p] 最佳的配置設置取決于(其中一些因素)應用程序代碼、運行所在的系統硬件和客戶機工作負荷。找到最佳設置的唯一方法是進行性能測試,這是我們在下一個技巧中所要討論的。[/p]
[p][b]技巧 27:進行性能測試[/b][/p]
[p] 正如我們在前面已經講過,性能是一個特征。如果您想要改善站點的性能,那么就制定一個性能目標,然后逐步改進,直到達到目標為止。不要,就不進行任何性能測試。通常,在項目結束時,再作必需的結構調整已經為時太晚,您的客戶將為此感到失望。將性能測試作為您日常測試的一部分來進行。可以對單個組件分別進行性能測試,如針對 asp 頁或 com 對象,或將站點作為一個整體來測試。[/p]
[p] 許多人使用單個瀏覽器請求頁面,來測試 web 站點的性能。這樣做就會給您一個感覺,即站點的響應能力很好,但這樣做實際上并不能告訴您在負載條件下站點的性能如何。[/p]
[p] 一般情況下,要想準確地測試性能,您需要一個專門的測試環境。此環境應包括硬件,其處理器速度、處理器數量、內存、磁盤、網絡配置等方面與生產環境的硬件相似。其次,您必須指定客戶機的工作負荷:有多少同時的用戶,他們發出請求的頻率,他們點擊頁面的類型等等。如果您沒有站點實際使用情況的數據,您必須估計一下使用的情況。最后,您需要一個可以模擬預期客戶機工作負荷的工具。有了這些工具,您就可以開始回答諸如“如果我有 n 個同時的用戶,那么需要多少服務器?”之類的問題。您還可以找出出現瓶頸的原因,并以此為目標進行優化。[/p]
[p] 下面列出了一些好的 web 負載測試工具。我們特別推薦 microsoft web application stress (was) 工具包。was 可使您記錄測試腳本,然后模擬數百或成千上萬個用戶訪問 web 服務器。was 報告很多統計信息,包括每秒鐘的請求數,響應時間分布情況和錯誤計數。was 有豐富的客戶機界面和基于 web 的界面兩種,web 界面可使您進行遠程測試。[/p]
[p] 一定要閱讀 iis 5.0 tuning guide。[/p]
[p][b]技巧 28:閱讀資源鏈接[/b][/p]
[p] 下面是一些與性能有關的出色的資源鏈接。如果您想了解有關信息,請閱讀 developing scalable web applications。[/p]
資源
[p]優化 asp 腳本 [br] developing scalable web applications[/p]
[p] got any cache? nancy winnick cluts 著[/p]
[p] maximizing the performance of your active server pages,nancy winnick cluts 著[/p]
[p] 15 seconds: performance section[/p]
[p] enhancing performance in asp - part i,wayne plourde 著[/p]
[p] when is better worse? weighing the technology trade-offs,nancy winnick cluts 著[/p]
[p] speed and optimization resources,charles carroll 著[/p]
[p][b]優化 iis[/b][/p]
[p] the art and science of web server tuning with internet information services 5.0[/p]
[p] leveraging asp in iis 5.0,j.d. meier 著[/p]
[p] tuning iis 4.0 for high volume sites,michael stephenson 著[/p]
[p] tuning internet information server performance,mike moore 著[/p]
[p] navigating the maze of settings for web server performance optimization,todd wanke 著[/p]
[p] managing internet information server 4.0 for performance,hans hugli 著[/p]
[p][b]ado 和 sql server[/b][/p]
[p] top ten tips: accessing sql through ado and asp,j.d. meier 著[/p]
[p] improve the performance of your mdac application,suresh kannan 著[/p]
[p] pooling in the microsoft data access components,leland ahlbeck 和 don willits 合著[/p]
[p] sql server: performance benchmarks and guides[/p]
[p] improving the performance of data access components with iis 4.0,leland ahlbeck 著[/p]
[p] microsoft data access components (mdac) and activex data objects (ado) performance tips,leland ahlbeck 著[/p]
[p] microsoft sql server 7.0 practical performance tuning and optimization - the server perspective,damien lindauer 著[/p]
[p] microsoft sql server 7.0 practical performance tuning and optimization - the application perspective,damien lindauer 著[/p]
[p] accessing recordsets over the internet,dino esposito 著[/p]
[p][b]asp 組件和線程模型[/b][/p]
[p] asp component guidelines,j.d. meier 著[/p]
[p] q243548: info: design guidelines for vb components under asp[/p]
[p] threading models explained,nancy winnick cluts 著[/p]
[p] so happy together? using activex components with active server pages,nancy winnick cluts 著[/p]
[p] developing active server components with atl,george reilly 著[/p]
[p] agility in server components,neil allain 著[/p]
[p] building high-performance middle-tier components with c++,jon flanders 著[/p]
[p] active server pages and com apartments,don box 著[/p]
[p] house of com: active server pages,don box 著[/p]
[p] house of com: contexts,don box 著[/p]
[p] house of com: performance trade-offs of the windows 2000 component execution environment,don box 著[/p]
[p] building com components that take full advantage of visual basic and scripting,ivo salmre 著[/p]
[p] component design principles for mts[/p]
[p][b]詞典組件[/b][/p]
[p] creating a page cache object,robert coleridge 著[/p]
[p] abridging the dictionary object: the asp team creates a lookup-table object,robert carter 著[/p]
[p] caprock dictionary[/p]
[p] site server commerce edition includes a dictionary component[/p]
[p][b]會話狀態[/b][/p]
[p] q175167: howto: persisting values without sessions[/p]
[p] q157906: howto: how to maintain state across pages with vbscript[/p]
[p] xml-based persistence behaviors fix web farm headaches,aaron skonnard 著[/p]
[p] house of com: stateless programming,don box 著[/p]
[p][b]性能和擴展性[/b][/p]
[p] blueprint for building web sites using the microsoft windows dna platform[/p]
[p] server performance and scalability killers,george reilly 著[/p]
[p] microsoft visual studio scalability center[/p]
[p] fitch & mather stocks 2000[/p]
[p] tuning the fmstocks application[/p]
[p] high-performance visual basic apps,ken spencer 著[/p]
[p] duwamish books,phase 4[/p]
[p] top windows dna performance mistakes and how to prevent them,gary geiger 和 jon pulsipher 合著[/p]
[p] building from static html to high-performance web-farms,shawn bice 著[/p]
[p][b]工具[/b][/p]
[p] microsoft web application stress tool[/p]
[p] i can't stress it enough -- load test your asp application,j.d. meier 著[/p]
[p] windows dna performance kit[/p]
[p] monitoring events in distributed applications using visual studio analyzer,mai-lan tomsen 著[/p]
[p][b]書目[/b][/p]
[p] professional active server pages 3.0,wrox press(特別是第 26 章:optimizing asp performance,george reilly 和 matthew gibbs 合著)。[/p]
[p] microsoft internet information services 5.0 resource guide(與 windows 2000 server resource kit 在一起),microsoft press。[/p]
[p] microsoft internet information server resource kit(用于 iis 4.0),microsoft press。[/p]
[p] programming distributed applications with com and microsoft visual basic 6.0,ted pattison 著,microsoft press。[/p]
[p] effective com,don box、keith brown、tim ewald 和 chris sells 合著;addison-wesley。[/p]
[p] developing web usability: the practice of simplicity,jakob nielsen 著,new riders。[/p]
[p][b]asp web 站點[/b][/p]
[p] microsoft technet for iis[/p]
[p] learnasp.com[/p]
[p] 4guysfromrolla.com[/p]
[p] 15seconds.com[/p]
[p] asptoday.com[/p]
[p] asp101.com[/p]
[p] asplists.com。許多專業的郵件列表包括:[/p]
[p] fast code! [br] asp advanced [br] not newbiestate management [br] scalability [br] visual basic components [br] xml [br] c++/atl component building [br] useit.com: web 可用性[/p]
[p][b]asp 樣式[/b][/p]
[p] asp best practices,george reilly 著[/p]
[p] asp quick lessons,charles carroll 著[/p]
[p] planning for asp,john meade 著[/p]
[p] asp guidelines,j.d. meier 著[/p]
[p][b]xml[/b][/p]
[p] inside xml performance,chris lovett 著[/p]
[p] inside msxml3 performance,chris lovett 著[/p]
該文章在 2010/7/3 13:25:30 編輯過
關鍵字查詢
優化
微軟
建議
相關文章
正在查詢...
Copyright 2010-2025
ClickSun
All Rights Reserved
黄频国产免费高清视频,久久不卡精品中文字幕一区,激情五月天AV电影在线观看,欧美国产韩国日本一区二区
亚洲福利在线视频
|
一本国产在线视频
|
亚洲人成在线播放a偷伦
|
中文字幕亚洲综合久久2020
|
在线一区十区精品
|
中文字幕久久久久久精
|