diff --git a/sparrow.ps1 b/sparrow.ps1 index a5e38d9cd62aaa25846908186d821c0d43646ced..6a6ba7db83a03d6607361737952dce5f570b0267 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 2bfce1653476b358b9093db83dbc2d90b73c4bba..bfecd8c35af225fcf0250f0de1da6b42df944974 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)