about summary refs log tree commit diff
path: root/gcc.sh
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2024-04-11 20:44:16 -0400
committerZach DeCook <zachdecook@librem.one>2024-04-11 20:45:04 -0400
commitc07d7af7266b9436c8aa86ca6394678d1a75fa55 (patch)
tree5cdf309db337c84495acb1e2253d4f967d65be71 /gcc.sh
parent332053c7090a917ba0860fd9b05879172724ba17 (diff)
downloadcgi-bin-c07d7af7266b9436c8aa86ca6394678d1a75fa55.tar.gz
gcc.sh: Cache the hymn pages
Some crawlers hit them a lot... this should make it a lot faster
Diffstat (limited to 'gcc.sh')
-rwxr-xr-xgcc.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc.sh b/gcc.sh
index d831072..89ec94c 100755
--- a/gcc.sh
+++ b/gcc.sh
@@ -25,6 +25,12 @@ fi
 
 printf "20 text/gemini\r\n"
 printf "=>/cgi-bin/gcc.sh$PATH_INFO?.mp3 Listen to this!\n"
+
+if test -e "gcc.cache$PATH_INFO"; then
+	cat "gcc.cache$PATH_INFO"
+	exit 0
+fi
+
 wget -q -O - https://gccsatx.com/hymns$PATH_INFO/ \
 | grep -o '\(<strong>\|<p>\|\)[^<>]*\(</strong>\|</p>\|<br />\)' \
 | sed 's@<br />@@g'| sed 's@^<strong>@\n## @g' | sed 's@</strong>@@g' | sed 's@</p>@@g' | sed 's@<p>@@g' \
@@ -33,5 +39,5 @@ wget -q -O - https://gccsatx.com/hymns$PATH_INFO/ \
 | grep -v '!important' | grep -v '}\|{\|wp-smiley' \
 | sed 's/&#8216;/‘/g' |sed 's/&#8217;/’/g' | sed 's/&#8221;/”/g' | sed 's/&#8220;/“/g'\
 | grep -v 'this website' \
-| sed -r '/^\s*$/d'
+| sed -r '/^\s*$/d' | tee "gcc.cache$PATH_INFO"
 exit 0