近日工作遇到一個另人困惑的問題,同一個頁面,用不同的瀏覽器訪問會有不同的問題
Firefox和IE瀏覽器一切正常沒有問題,但是當用Webkit核心瀏覽器訪問時,驗證碼無論如何通不過驗證。
瀏覽伺服器端日誌,發現提交的資料都是一樣的。
再仔細分析日誌,發現載入流程不一樣的:
WebKit流程如下:
Processing CharmsController#index (for 127.0.0.1 at 2011-04-29 17:37:25) [GET]
Processing SimpleCaptchaController#simple_captcha (for 127.0.0.1 at 2011-04-29 17:37:29) [GET]
Processing SiteController#show_page (for 127.0.0.1 at 2011-04-29 17:37:30) [GET] //這裡發生302錯誤
Processing CharmsController#index (for 127.0.0.1 at 2011-04-29 17:37:31) [GET]
Processing SiteController#show_page (for 127.0.0.1 at 2011-04-29 17:37:32) [GET] //這裡發生302錯誤
Processing SiteController#show_page (for 127.0.0.1 at 2011-04-29 17:37:33) [GET] //這裡發生302錯誤
Processing CharmsController#index (for 127.0.0.1 at 2011-04-29 17:37:35) [GET]
發現index載入了三次,導致驗證碼更新了三次(訪問index會更新驗證碼)但是卻只載入了一次。
Firefox和IE核心載入流程:
Processing CharmsController#index (for 127.0.0.1 at 2011-04-29 17:37:25) [GET]
Processing SimpleCaptchaController#simple_captcha (for 127.0.0.1 at 2011-04-29 17:37:29) [GET]
Processing SiteController#show_page (for 127.0.0.1 at 2011-04-29 17:37:30) [GET] //這裡發生302錯誤
Processing SiteController#show_page (for 127.0.0.1 at 2011-04-29 17:37:32) [GET] //這裡發生302錯誤
Processing SiteController#show_page (for 127.0.0.1 at 2011-04-29 17:37:33) [GET] //這裡發生302錯誤
但是在IE下index卻只載入了一次
不知道為什麼WebKit會對同一個頁面載入三次,難道是因為發生了302錯誤?
剛剛又測試了一下,把找不到的圖片都添加上,則頁面只載入一次,看來WebKit在頁面上有圖片找不到時會重新請求頁面,但次數是多少我沒有測試。