What can cause a double page request?

白昼怎懂夜的黑 提交于 2019-11-29 15:31:45

The causes I've seen before:

  • Missing stylesheet or image

  • Web developer addon for Chrome/Firefox sometimes requests things twice if you're validating HTML etc.

  • Browser inconsistency

Sometimes it's just too difficult to track down the root cause of a double request.

Either way, you should NOT be changing database state (or session state) through a GET request. The only SQL query you should be running without postdata is SELECT. All updates and inserts should be done using forms, even if the form consists only of a submit button.

I have sat beside people whom I would swear knew better than this, and watch aghast as they double-clicked on every hyperlink in our app.

Didn't take long to figure out why they were experiencing double the page load time of everyone else...

Things like this certainly tend to give one pause when implementing pages that change the backend state. A lot of people put sequence numbers in hidden form elements so the backend can detect a double-submit.

src="" in certain elements on certain browsers (such as <img src="" />) can request the current page again.

404's are a prime source for a request seemingly being requested twice. Check your CSS, JS and image sources are all correct.

We had a very strange behaviour in our CMS where an iframe in a jQuery dialog lightbox made a doubled database insert. After hours of debugging and loud WTFs we nailed it down. the dialog close method was setting the focus to the iframe of the dialog before destroying it and caused a reload of the iframe url!

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!