OpenLayers OpenLayers

Changeset 1904

Show
Ignore:
Timestamp:
11/18/06 09:42:35 (2 years ago)
Author:
crschmidt
Message:

non-deterministic server choice is a bad idea. When I view a tile, I may get caching
headers with that URL from a properly configured server. By randomly changing the
server I request from, the browser has to store up to numUrls caches for each tile.
Instead, make this deterministic based on the integer value of the request parameters,
modded into the severs array. Deployed on labs.metacarta.com/wms-c/demo.html.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/crschmidt/multiserverwms/lib/OpenLayers/Layer/HTTPRequest.js

    r1862 r1904  
    110110        var url = (altUrl == null) ? this.url : altUrl; 
    111111         
    112         if (typeof url == "object") { 
    113             url = url[Math.floor(Math.random()*url.length)]; 
    114         }    
    115         // requestString always starts with url 
    116         var requestString = url;         
    117  
    118112        // create a new params hashtable with all the layer params and the  
    119113        // new params together. then convert to string 
     
    121115        var allParams = OpenLayers.Util.extend(allParams, newParams); 
    122116        var paramsString = OpenLayers.Util.getParameterString(allParams); 
     117        if (typeof url == "object") { 
     118            var serverid=0; 
     119            for (var i=0; i<paramsString.length; i++) {  
     120              serverid += paramsString.charCodeAt(i);  
     121            } 
     122            url = url[serverid%url.length]; 
     123        }    
     124         
     125        // requestString always starts with url 
     126        var requestString = url;         
     127         
    123128        if (paramsString != "") { 
    124129            var lastServerChar = url.charAt(url.length - 1);