Skip to content

Instantly share code, notes, and snippets.

@bmiro
Created May 7, 2018 14:37
Show Gist options
  • Save bmiro/f3beb03b78a7bb82d92b7a26301c815c to your computer and use it in GitHub Desktop.
Save bmiro/f3beb03b78a7bb82d92b7a26301c815c to your computer and use it in GitHub Desktop.
Lua snippet for wrk to skip caches by adding a querystring
-- Lua snippet to use with wrk to test (stress / benchmark) urls skipping CDN / Framework / misc
-- cache by adding a 'random' querystring
--
-- To use it adjust wrk params and do something like this:
-- docker run --rm -v $(pwd)/cache-killer.lua:/cache-killer.lua skandyla/wrk -c 1 -d 1 -t 1 --script /cache-killer.lua http://www.yoursite/testpath
request = function()
path = wrk.path
if path.find(path, "?") then
path = path .. "&"
else
path = path .. "?"
end
killer = tostring(math.random())
time = tostring(os.time())
path = path .. "cache-killer=" .. killer .. "&" .. time
return wrk.format(nil, path)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment