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
feita há 4 meses175 visualizações
1 Resposta
0
AWS
SeanM
respondido há 4 meses
profile picture
ESPECIALISTA
avaliado há um mês

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas