Skip to content

Instantly share code, notes, and snippets.

@dvershinin
Last active October 29, 2019 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvershinin/7c5cd31c80668493a560b5e8691c53ea to your computer and use it in GitHub Desktop.
Save dvershinin/7c5cd31c80668493a560b5e8691c53ea to your computer and use it in GitHub Desktop.
Check for disappearing cache
#!/bin/bash
# Run e.g. check-cache.sh https://www.manzara.si/jakne
# Or time ./check-cache.sh https://www.manzara.si/jakne
if [ $# -eq 0 ]
then
echo "Error: Please specify request URL as argument."
exit 1
fi
TEST_URL="$1"
# run initial warmup
curl -s -L -D /dev/stdout -o initial.html "${TEST_URL}"
# next request should be Hit
X_CACHE="None"
counter=0
until [ "${X_CACHE}" = "MISS" ]
do
((counter++))
echo "Request #${counter}..."
X_CACHE=$(curl -s -L -D /dev/stdout -o current.html "${TEST_URL}" | grep --ignore-case --only-matching --perl-regexp "X-Cache: \K\w+")
echo "Received Cache Status: ${X_CACHE}"
sleep 1
done
echo "Got MISS! Bail! Investigate initial.html vs current.html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment