Skip to content

Commit df713cc

Browse files
fix: add cache-busting to download URLs to prevent inflated speed measurements
1 parent 04fdd6e commit df713cc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/speedtest.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,14 @@ pub fn test_download(
252252
payload_size_bytes: usize,
253253
output_format: OutputFormat,
254254
) -> f64 {
255-
let url = &format!("{BASE_URL}/{DOWNLOAD_URL}{payload_size_bytes}");
255+
let timestamp = std::time::SystemTime::now()
256+
.duration_since(std::time::UNIX_EPOCH)
257+
.unwrap()
258+
.as_nanos();
259+
let url = &format!(
260+
"{BASE_URL}/{DOWNLOAD_URL}{payload_size_bytes}&t={}",
261+
timestamp
262+
);
256263
let req_builder = client.get(url);
257264
let (status_code, mbits, duration) = {
258265
let response = req_builder.send().expect("failed to get response");

0 commit comments

Comments
 (0)