Setting the img, script, and link tags in the page as empty links can cause excessive page requests, including IE, Firefox, chrome, and Safari! However, when the src and href values of the script and link are empty compared with img, no request is made in IE, whereas Chrome, Safari, and Firefox will have a redundant new request. The following describes in detail:
Analysis of empty img src
Whether writing in html or creating var img = new Image (); img. src = "";, will lead to more requests to your server. The specific request analysis is as follows:
In IE, this will request the directory of the current page once. If this empty src label appears in the http://js8.in/demo/a.html, it will cause a re-Request: http://js8.in/demo/
In Safari and Chrome, the current page is requested.
In versions earlier than Firefox 3.5, the problem is the same as that in Safari, but this BUG was fixed in Firefox 3.5.
In Opera, no additional requests are made.
In a website with a low access volume, it doesn't matter if you have another such request (or even double your website's browsing), but in a website with tens of millions or even higher access volume, this will significantly increase your server and bandwidth costs. Another risk is that a new request to a page may result in unintentional modification of user information, such as cookies or ajax operations.
You will never write such code?
I don't think so. This often happens accidentally, for example, the following php code:
You originally planned to read this src address from the server, but for some reason, this address has not been set, or the Code BUG causes the read to fail, and an empty src tag will appear.
Will empty src in other labels cause such a problem?
The good news is that only the image Tag in IE has this problem.
In Chrome, Safari, and Firefox, both <script src = ""> and <link href = ""> lead to a new request.
How can this problem be solved?
You can start from two aspects. First, try to avoid this bad programming method and avoid empty src labels. In addition, you can start from the server side and do not return anything to the client when discovering such meaningless requests.
<? Php
$ Referrer = isset ($ _ SERVER ['HTTP _ referer'])? $ _ SERVER ['HTTP _ referer']: '';
$ Url = "http: //". $ _ SERVER ['HTTP _ host']. $ _ SERVER ['request _ URI '];
If ($ referrer ==$ url ){
Exit;
}
?>
Link: http://www.js8.in/555.html