created A/B test routing with cloudfront function

0

I have the following libs convention in my s3 origin serving/[0....19]/somefile.pm.js. and i added a the following cloudfront function to the viewer request . i want to randomly pick equally from libs 0 - 19 when we hit a request from the the following file path : https://myurl.com/serving/somefile.pm.js.

the final goal is to create A/B testing - the question is - if this function reliable to achieve that ? for instance

the file version in libs [0 - 9] was created/modifed and validated 4 weeks ago and a new version is deployed now for libs [10 -19] .. is this test good to go and can I trust that this way cloudfront will serve the 2 versions rate of 50/50??

function insertLib(request) { var originalURL = request.uri var headers = request.headers var pubmaxserver = headers["pubmaxserver"]; var lib = null if(pubmaxserver && pubmaxserver.value == '0' ){ lib = '0' } if(pubmaxserver && pubmaxserver.value ){ lib = pubmaxserver.value }

if (!originalURL.includes("serving") && originalURL.endsWith(".pm.js")) {
    if(!lib){
       lib = Math.floor(Math.random() * 20); 
    }
    originalURL =  originalURL.split(".pm.js")[0].replace("/","/serving/"+ lib +"/") +".pm.js"
}

// If the URL doesn't end with ".pm.js" or if the random number is >= the specified percentage, return the original URL
return originalURL;

}

Ronen
posta 4 mesi fa175 visualizzazioni
1 Risposta
0
AWS
SeanM
con risposta 4 mesi fa
profile picture
ESPERTO
verificato un mese fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande