IE8, Javascript includes & Apache Error Logs
I mentioned this over at webdeveloper.com a while ago, and it’s still an issue that I’m running in to.
Apache error_logs are showing quite a lot of “file does not exist” errors for pages using rewrites. For example, you could visit “http://www.mydomain.co.uk/product/103697.html” and the error log would show “http://www.mydomain.co.uk/product” with the file does not exist error.
Fine (I thought) as the referrer is the page, it must be that there is a broken link.
No such luck – no broken links on the page, and seemingly nothing wrong. In fact, while I’m looking at the specific site that I noticed the issue on first, it appears that I’m not affecting the error_logs at all. None of my browsing is causing errors.
So, I switched to the access_logs and started looking for times & dates of the errors. Turns out, all users were using IE8.
Cutting a long story short, I figured out – by looking at the number of errors that would appear on each page request – that the issue had something to do with Javascript includes on the page.
All the javascript pages were referenced in the header include file as relative i.e <script type=”text/javascript” src=”js/monkey.js”></script> There has never been an issue with this – until now – and specifically with IE8.
I do seem to remember something about the new rendering engine in IE8 parsing the page several times to pull in content I don’t see how a browser rather than an specific action could be causing an Apache error.
To fix the issue, making the javascript files “more” relative cured the problem. Altering the source to “/js/monkey.js” fixed the issue.
To be honest, it’s got me stumped. Can anyone shed any light on this?
Related posts
You may be interested in the following related posts:

Steve Fenton
There is an explanation to this.
With “/js/monkey.js”, this is treated as a path relative to the application root.
With “js/monkey.js”, this is treated as a path relative to the current address.
Here are some examples:
On http://www.mydomain.co.uk/, both includes would be pointing at /js/monkey.js
On http://www.mydomain.co.uk/products/, the first script would still be pointing at /js/monkey.js but the second (without the leading slash) would be pointing at /products/js/monkey.js
Douglas Radburn
Hi Steve,
Of course, you’re right, however, the error log was reporting an entry against “http://www.mydomain.co.uk/products” NOT the JS file that was to be included.
I could see why apache would report that it couldn’t find the JS, but it could. In the temptate used at the time, the base href tag actually sorted the relative issue anyway.