Dear list,<br><br>this is second time I make this post: for some reason the first post was lost... and it's good because it was buggy!<br><br>On to the problem: pink tiles showing up in FireFox.<br><br>The pink tiles are generated because of too many connections, so my problem it's not that there are pink tiles, the problem it's that when the server is reachable again, if I for ex. zoom in and out, they don't desappear as they should.<br>
This is because of aggressive caching on tile to be displayed. If I
disable caching on server side for tiles, they behave ok... bu I want
tiles to be able to cache them on clients!<br><br>After some days fighting against this problem, enabling caching, disabling caching.......... I decided to inspect Openlayers code. It' not all really clear, but I realized that the problem <i>can be</i> related to "<b>OpenLayers.Util.onImageLoadError</b>".<br>
Finally I realized that changing it as reported will fix my problem:<br><br><span style="font-family: courier new,monospace;">OpenLayers.Util.onImageLoadError
= function() {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> this._attempts =
(this._attempts) ? (this._attempts + 1) : 1;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (this._attempts
<= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> var urls = this.urls;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if (urls
&& urls instanceof Array && urls.length > 1) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> var src = this.src.toString();</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> var
current_url, k;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> for (k = 0;
current_url = urls[k]; k++) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> if
(src.indexOf(current_url) != -1) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
break;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> var guess =
Math.floor(urls.length * Math.random());</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> var new_url = urls[guess];</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> k = 0;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> while (new_url == current_url
&& k++ < 4) {</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> guess =
Math.floor(urls.length * Math.random());</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> new_url = urls[guess];</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> this.src = src.replace(current_url,
new_url);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> } else {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> this.src = this.src;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <i><b>OpenLayers.Console.log("attemp
n.:",this._attempts);</b></i></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> } else {</span><br style="font-family: courier new,monospace;"><font size="4"><span style="font-family: courier new,monospace;"> <i><b>OpenLayers.Console.log("error
loading", "appending uuu!");</b></i></span><i><b><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> var dummy = "&uuu";<br> if (this.src.match(dummy + "$") != dummy) {<font size="2"> //only add if it was not added before</font><br>
this.src = this.src + "&uuu";<br> }</span></b></i><br style="font-family: courier new,monospace;"></font><span style="font-family: courier new,monospace;">
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> this.style.display = "";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">};</span><br><br clear="all">That is: I change the the url of the tile appending some dummy character
[in this case "uuu", but it can be anything].<br>This can be done only if the dummy string was not added before [first post bug: I didn't check it]. If you don't check It and the address <i>this.src</i> is wrong, you will get OL to continue adding the dummy string going in loop and bombardig the server with requests.<br>
I don't know enough OL to understand why, but that's it.<br><br>I would like to have comments from people who knows OL better than me about this "solution".<br><br>NOTE: it's possible to use the same technique without modifying OL, doing something <b><i>like</i></b> [untested - must be sure about what is '<b>this</b>' in the context]:<br>
<br><span style="font-family: courier new,monospace;">OpenLayers.Util.oldOnImageLoadError</span> = <span style="font-family: courier new,monospace;">OpenLayers.Util.onImageLoadError;</span><br><span style="font-family: courier new,monospace;">OpenLayers.Util.onImageLoadError = function() {<br>
this.</span><span style="font-family: courier new,monospace;">oldOnImageLoadError</span><span style="font-family: courier new,monospace;">();</span><br><span style="font-family: courier new,monospace;"> if (this._attempts >= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {</span><br>
<span style="font-family: courier new,monospace;"> //TODO: add dummy</span><br><span style="font-family: courier new,monospace;"> }</span><br><span style="font-family: courier new,monospace;">}<br></span><br>Pietro Ianniello<br>
<br>
<br><br>