diff --git a/lib/run-pagespeed.js b/lib/run-pagespeed.js index 5c6127c..25710eb 100644 --- a/lib/run-pagespeed.js +++ b/lib/run-pagespeed.js @@ -4,7 +4,10 @@ const baseUrl = 'https://www.googleapis.com/pagespeedonline/v5/runPagespeed'; async function runPagespeed(urlString, strategy) { const url = new URL(urlString); - url.searchParams.append('pagespeed-nocache', Date.now()); + if(!url.hash) { + // bust PSI cache but not your CDN's cache + url.hash = `#${Date.now().toString().substring(6)}` + } const queryOptions = { url: url.toString(), strategy: strategy || 'mobile', diff --git a/tests/__snapshots__/run-pagespeed.test.js.snap b/tests/__snapshots__/run-pagespeed.test.js.snap index bce52ab..25bbf46 100644 --- a/tests/__snapshots__/run-pagespeed.test.js.snap +++ b/tests/__snapshots__/run-pagespeed.test.js.snap @@ -2,7 +2,7 @@ exports[`run-pagespeed runPageSpeed calls Desktop API and returns Lighthouse result 1`] = ` Array [ - "https://www.googleapis.com/pagespeedonline/v5/runPagespeed/?url=https%3A%2F%2Fwww.google.com%2F%3Fpagespeed-nocache%3D1479427200000&strategy=desktop", + "https://www.googleapis.com/pagespeedonline/v5/runPagespeed/?url=https%3A%2F%2Fwww.google.com%2F%237200000&strategy=desktop", Object { "json": true, }, @@ -11,7 +11,7 @@ Array [ exports[`run-pagespeed runPageSpeed calls Mobile API and returns Lighthouse result 1`] = ` Array [ - "https://www.googleapis.com/pagespeedonline/v5/runPagespeed/?url=https%3A%2F%2Fwww.google.com%2F%3Fpagespeed-nocache%3D1479427200000&strategy=mobile", + "https://www.googleapis.com/pagespeedonline/v5/runPagespeed/?url=https%3A%2F%2Fwww.google.com%2F%237200000&strategy=mobile", Object { "json": true, },