Last active
May 20, 2024 03:21
-
-
Save erikhansen/c1b88dce68c8cd76b042c1e1b82b0703 to your computer and use it in GitHub Desktop.
Load all urls from a sitemap.xml file
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
#!/bin/bash | |
# This script crawls all urls in a /sitemap.xml file and loads them, effectively priming the cache | |
# Usage: ./warm_cache.sh www.example.com | |
time wget --quiet https://$1/sitemap.xml --output-document - | \ | |
egrep -o "https?://[^<]+" | \ | |
grep $1 | \ | |
grep -v "jpg" | \ | |
xargs -i -d '\n' curl --output /dev/null --silent --write-out '%{http_code} %{time_total}ms %{url_effective} \n' {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While caching shouldn't solely be relied upon for site performance, there are certain instances where priming the cache is useful. In my case, a client regularly imports products with hundreds of images each (for 360° views) and when the PDP is loaded for the first time, it takes 1-2 minutes for Magento to generate the product images. In my case, the
php bin/magento catalog:images:resize
command does not generate the images necessary since the 360° images are powered by a third-party extension and don't tie into that command.Example output of this script: