From 6f3d20ca2e1cbec6c308ce8dd3bf7be0c230a191 Mon Sep 17 00:00:00 2001 From: "Dominik.Sigmund" <dominik.sigmund@br.de> Date: Thu, 10 Oct 2024 12:26:49 +0200 Subject: [PATCH] Added Random QUery Parameter to further ignore cache --- sparrow.ps1 | 6 +++++- sparrow.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sparrow.ps1 b/sparrow.ps1 index a5e38d9..6a6ba7d 100644 --- a/sparrow.ps1 +++ b/sparrow.ps1 @@ -18,11 +18,15 @@ function Perform-Curl { [int]$iteration ) + # Generate a random query parameter to avoid cache + $randomQuery = "nocache=" + [guid]::NewGuid().ToString() + $fullUrl = "$url?$randomQuery" + # Get the current date and time for the test $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss" # Perform the curl request, measure time and bypass cache - $curlOutput = curl.exe -o NUL -s -w "`%{time_starttransfer};`%{time_total}" -H "Cache-Control: no-cache" $url + $curlOutput = curl.exe -o NUL -s -w "`%{time_starttransfer};`%{time_total}" -H "Cache-Control: no-cache" $fullUrl $outputParts = $curlOutput -split ';' $ttfb = $outputParts[0] diff --git a/sparrow.sh b/sparrow.sh index 2bfce16..bfecd8c 100755 --- a/sparrow.sh +++ b/sparrow.sh @@ -22,13 +22,17 @@ perform_curl() { file_type=$2 iteration=$3 + # Generate a random query parameter to avoid cache + random_query="nocache=$(date +%s%N)" + full_url="${url}?${random_query}" + # Get the current date and time for the test timestamp=$(date +"%Y-%m-%d %H:%M:%S") # Perform the curl request, measure time and bypass cache curl_output=$(curl -o /dev/null -s -w "%{time_starttransfer};%{time_total}\n" \ -H 'Cache-Control: no-cache' \ - "$url") + "$full_url") ttfb=$(echo "$curl_output" | cut -d ';' -f 1) total_time=$(echo "$curl_output" | cut -d ';' -f 2) -- GitLab