Potential Workaround Found!
Background:
So I had a website I was working on that was experiencing this problem pretty badly. I found that some phones were more likely to exhibit the behavior than others. I used the phones that were the worst offenders, and performed the following steps to be able to somewhat reliably reproduce the issue. Even on the worst phones, while following these steps, I was only able to get 50% reliability on reproducing the issue, so with all code tests, I'd recommend repeating the steps several times to determine if a change had been made.
Steps to reproduce:
- Open page that is exhibiting the issue in Safari Mobile on iOS8
- Close Safari
- Reopen Safari (should by default bring you back to the page)
- Check this page very carefully for misplaced.
- Close Safari, and repeat steps 3-5.
- On the worst phones, this would happen 50% of the time, so I would have to repeat the entire process several times to confirm / deny whether or not what I did was helping the issue.
Cause:
I'm not sure if it's the same cause for all of you, but in my case, it resulted from a specific set of response headers associated with a CSS file. When present, the problem would appears 50% of the time, once removed, the problem has not returned. The way I determined this, was removing all scripts / style assets from the page and found that the the issue disappeared. I then slowly started reintroducing assets until the problem returned, and looked very closely at the files.
I was able to get even an empty .css file, to cause the image swapping bug, if the response headers were as follows:
Bad:
Cache-Control:no-cache
Connection:close
Content-Encoding:gzip
Content-Type:text/css;charset=UTF-8
Date:Sat, 10 Jan 2015 13:08:36 GMT
Server:Apache/2.2.15 (Red Hat)
Vary:Accept-Encoding
X-Powered-By:PHP/5.4.28
Fix:
I removed the special handling associated with the file, and got these were the default headers that were sent with the file, and it worked:
Good:
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:234
Content-Type:text/html; charset=UTF-8
Date:Sat, 10 Jan 2015 13:09:13 GMT
Keep-Alive:timeout=8, max=200
Server:Apache/2.2.15 (Red Hat)
Vary:Accept-Encoding
X-Powered-By:PHP/5.4.28
I believe the issue was related to either the no-cache, or the lack of content-length, but in either case, this triggered the bug within Safari to start swapping images.
Your mileage may vary, but hopefully the above will help, good luck!