Tags: #bash #wildcard #glob #contains
#!/bin/bash
# our CDN was serving stale content for a request that shouldn't be
# so we wrote a quick script to verify the behaviour wasn't happening
# more often than it should.
function get {
local id=$1
local url="https://www.example.com/?id=$id"
local response=$(curl -D - -so /dev/null -H 'X-Debug:1' "$url")
local state=$(echo "$response" | grep 'Foo-State')
echo "$state"
}
for i in {1..50}
do
uid="attempt-$i-$(uuidgen)"
result1=$(get "$uid")
result2=$(get "$uid")
if [[ "$result2" == *"HIT-STALE"* ]]; then
echo "$uid: got stale :-("
elif [[ "$result2" == *"HIT-"* ]]; then
echo "$uid: was fine :-)"
fi
done