Improve nginx caching and use redirects for i18n

This commit is contained in:
wiz
2022-01-12 23:12:49 +09:00
parent 7a7e1f1f3b
commit 3c8a146302
8 changed files with 111 additions and 45 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env zsh
#!/usr/local/bin/zsh
PROTO=https
HOSTNAME=mempool.ninja
URL_BASE=${PROTO}://${HOSTNAME}
@@ -20,17 +20,23 @@ echo "Starting tests to ${URL_BASE}"
echo "Test locale for / with no header or cookie"
curl -s ${URL_BASE}/ | grep '<html lang' | tr -d '\r\n' | curltest '<html lang="en-US">'
echo "Test locale for / with 'ja' lang header and no cookie"
curl -s -H 'Accept-Language: ja' ${URL_BASE}/ | grep '<html lang' | tr -d '\r\n' | curltest '<html lang="ja">'
echo "Test locale for /ja with no header or cookie"
curl -s ${URL_BASE}/ja | grep '<html lang' | tr -d '\r\n' | curltest '<html lang="ja">'
#echo "Test locale for /ja with 'ja' lang header and 'en' lang cookie"
#curl -s -H 'Accept-Language: ja' --cookie 'lang=en' ${URL_BASE}/ja | grep '<html lang' | tr -d '\r\n' | curltest '<html lang="en-US">'
echo "Test redirect for / with 'ja' lang header and no cookie"
curl -i -s -H 'Accept-Language: ja' ${URL_BASE}/ | grep '^location:' | tr -d '\r\n' | curltest "location: ${URL_BASE}/ja/"
echo "Test locale for / with 'ja' lang header and 'en' lang cookie"
curl -s -H 'Accept-Language: ja' --cookie 'lang=en' ${URL_BASE}/ | grep '<html lang' | tr -d '\r\n' | curltest '<html lang="en-US">'
echo "Test locale for / with 'ja' lang header and 'sv' lang cookie"
curl -s -H 'Accept-Language: ja' --cookie 'lang=sv' ${URL_BASE}/ | grep '<html lang' | tr -d '\r\n' | curltest '<html lang="sv">'
echo "Test redirect for / with 'ja' lang header and 'sv' lang cookie"
curl -i -s -H 'Accept-Language: ja' --cookie 'lang=sv' ${URL_BASE}/ | grep '^location:' | tr -d '\r\n' | curltest "location: ${URL_BASE}/sv/"
echo "Test locale for / with 'ja' lang header and 'foo' lang cookie"
curl -s -H 'Accept-Language: ja' --cookie 'lang=foo' ${URL_BASE}/ | grep '<html lang' | tr -d '\r\n' | curltest '<html lang="ja">'
echo "Test redirect for / with 'ja' lang header and 'foo' lang cookie"
curl -i -s -H 'Accept-Language: ja' --cookie 'lang=foo' ${URL_BASE}/ | grep '^location:' | tr -d '\r\n' | curltest "location: ${URL_BASE}/ja/"
echo "Test rewrite for /resources/pools.json with no header and no cookie"
curl -s -i ${URL_BASE}/resources/pools.json | grep -i content-type | tr -d '\r\n' | curltest 'content-type: application/json'