使用template軟件包為客戶端生成動態網頁時,速度太慢。測試代碼如下,golang 1.4.1http.Handle("/js/", (http.FileServer(http.Dir(webpath))))http.Handle("/css/", (http.FileServer(http.Dir(webpath))))http.Handle("/img/", (http.FileServer(http.Dir(webpath))))http.HandleFunc("/test", TestHandler)func TestHandler(w http.ResponseWriter, r *http.Request) { Log.Info("Entering TestHandler ...") r.ParseForm() filename := NiConfig.webpath + "/test.html" t, err := template.ParseFiles(filename) if err != nil { Log.Error("template.ParseFiles err = %v", err) } t.Execute(w, nil)}根據日志,我發現在中花了大約3秒鐘t.Execute(w, nil),但我不知道為什么要花這么多時間。我還嘗試了Apache服務器進行測試test.html,它的響應速度非???。
- 2 回答
- 0 關注
- 591 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消