Cool, thanks for this, @lasvegas!
Since I wasn’t sure about having the swap on all the time, I created four tiny scripts based on your instructions. I’ll share here in case anyone wants similar reusable tools. (Your step 5 would only work if in that same swap directory from before.)
swapsetup.sh (only run once)
sudo mkdir -v /var/cache/swap
cd /var/cache/swap
sudo dd if=/dev/zero of=swapfile bs=1K count=1M
sudo chmod 600 swapfile
sudo mkswap swapfile
sudo swapon swapfile
top -bn1 | grep -i swap
swapon.sh (to turn on)
sudo swapon /var/cache/swap/swapfile
swapoff.sh (to turn off)
sudo swapoff /var/cache/swap/swapfile
swapcheck.sh (to see if/how much in use)
top -bn1 | grep -i swap