Last active
October 29, 2019 21:09
-
-
Save dvershinin/7c5cd31c80668493a560b5e8691c53ea to your computer and use it in GitHub Desktop.
Check for disappearing cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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