Created
November 21, 2022 08:08
-
-
Save j13k/26e388e64c77b12ed084fb7ff4e75766 to your computer and use it in GitHub Desktop.
Primes a WordPress website cache by crawling each resource linked in sitemap.xml.
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
#!/usr/bin/env bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
if [[ "${TRACE-0}" == "1" ]]; then | |
set -o xtrace | |
fi | |
usage() { | |
echo ' | |
Usage: ./prime_wordpress_website_cache.sh HOSTNAME | |
Primes a WordPress website cache by crawling each resource linked in sitemap.xml. | |
' | |
} | |
if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then | |
usage | |
exit | |
fi | |
if [ -z "${1-}" ]; then | |
echo ' | |
HOSTNAME not specified | |
' | |
usage | |
exit 1 | |
fi | |
#cd "$(dirname "$0")" | |
main() { | |
wget --quiet "https://${1}/sitemap.xml" --output-document - | | |
grep -Eo "https?://${1}/[^<]+" | | |
wget --quiet -i - --output-document - | | |
grep -Eo "https?://${1}/[^<]+" | | |
wget -i - --output-document /dev/null | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment