Skip to content

Instantly share code, notes, and snippets.

@deivisonarthur
Last active August 29, 2015 14:06
Show Gist options
  • Save deivisonarthur/9263c50c0230f282715d to your computer and use it in GitHub Desktop.
Save deivisonarthur/9263c50c0230f282715d to your computer and use it in GitHub Desktop.
root@ip-10-253-143-111:/mnt/www/lojamodelo/shell# ./warm-cache.sh http://lojamodelo.inovarti.com.br/sitemap.xml
Getting URLs from sitemap...
Warming 130 URLs using 1 processes...
HTTP/1.1 200 1.05 secs: 12187 bytes ==> GET /women/new-arrivals.html
HTTP/1.1 200 1.10 secs: 12098 bytes ==> GET /women/tops-blouses.html
HTTP/1.1 200 0.90 secs: 11632 bytes ==> GET /women/pants-denim.html
HTTP/1.1 200 0.93 secs: 12415 bytes ==> GET /women/dresses-skirts.html
HTTP/1.1 200 1.13 secs: 12117 bytes ==> GET /men/new-arrivals.html
HTTP/1.1 200 0.92 secs: 11867 bytes ==> GET /men/shirts.html
HTTP/1.1 200 1.08 secs: 11365 bytes ==> GET /men/tees-knits-and-polos.html
HTTP/1.1 200 1.11 secs: 11914 bytes ==> GET /men/pants-denim.html
HTTP/1.1 200 0.63 secs: 11014 bytes ==> GET /accessories/eyewear.html
HTTP/1.1 200 0.74 secs: 12088 bytes ==> GET /accessories/jewelry.html
HTTP/1.1 200 0.87 secs: 11980 bytes ==> GET /accessories/shoes.html
HTTP/1.1 200 0.76 secs: 12020 bytes ==> GET /accessories/bags-luggage.html
HTTP/1.1 200 0.58 secs: 11192 bytes ==> GET /home-decor/books-music.html
HTTP/1.1 200 0.84 secs: 12135 bytes ==> GET /home-decor/bed-bath.html
HTTP/1.1 200 0.77 secs: 13171 bytes ==> GET /home-decor/electronics.html
HTTP/1.1 200 0.71 secs: 11809 bytes ==> GET /home-decor/decorative-accents.html
HTTP/1.1 200 0.65 secs: 10915 bytes ==> GET /sale/women.html
HTTP/1.1 200 0.72 secs: 11210 bytes ==> GET /sale/men.html
HTTP/1.1 200 0.52 secs: 10739 bytes ==> GET /sale/accessories.html
HTTP/1.1 200 0.53 secs: 10645 bytes ==> GET /sale/home-decor.html
HTTP/1.1 200 0.12 secs: 8340 bytes ==> GET /women.html
HTTP/1.1 200 0.92 secs: 11445 bytes ==> GET /men/blazers.html
HTTP/1.1 200 0.13 secs: 8357 bytes ==> GET /men.html
HTTP/1.1 200 0.11 secs: 8541 bytes ==> GET /accessories.html
HTTP/1.1 200 0.13 secs: 8373 bytes ==> GET /home-decor.html
HTTP/1.1 200 0.14 secs: 11003 bytes ==> GET /sale.html
HTTP/1.1 200 0.13 secs: 10963 bytes ==> GET /vip.html
HTTP/1.1 200 3.16 secs: 12637 bytes ==> GET /aviator-sunglasses.html
HTTP/1.1 200 0.58 secs: 11917 bytes ==> GET /jackie-o-round-sunglasses.html
HTTP/1.1 200 0.50 secs: 11457 bytes ==> GET /retro-chic-eyeglasses.html
HTTP/1.1 200 1.52 secs: 16434 bytes ==> GET /isla-crossbody-handbag.html
HTTP/1.1 200 2.41 secs: 16154 bytes ==> GET /french-cuff-cotton-twill-oxford-611.html
root@ip-10-253-143-111:/mnt/www/lojamodelo/shell# ./warm-cache.sh http://lojamodelo.inovarti.com.br/sitemap.xml
Getting URLs from sitemap...
Warming 130 URLs using 1 processes...
HTTP/1.1 200 0.15 secs: 10892 bytes ==> GET /women/new-arrivals.html
HTTP/1.1 200 0.13 secs: 10847 bytes ==> GET /women/tops-blouses.html
HTTP/1.1 200 0.12 secs: 10405 bytes ==> GET /women/pants-denim.html
HTTP/1.1 200 0.12 secs: 11033 bytes ==> GET /women/dresses-skirts.html
HTTP/1.1 200 0.14 secs: 10831 bytes ==> GET /men/new-arrivals.html
HTTP/1.1 200 0.11 secs: 10604 bytes ==> GET /men/shirts.html
HTTP/1.1 200 0.12 secs: 10209 bytes ==> GET /men/tees-knits-and-polos.html
HTTP/1.1 200 0.14 secs: 10674 bytes ==> GET /men/pants-denim.html
HTTP/1.1 200 0.12 secs: 10039 bytes ==> GET /accessories/eyewear.html
HTTP/1.1 200 0.13 secs: 10814 bytes ==> GET /accessories/jewelry.html
HTTP/1.1 200 0.14 secs: 10748 bytes ==> GET /accessories/shoes.html
HTTP/1.1 200 0.13 secs: 10815 bytes ==> GET /accessories/bags-luggage.html
HTTP/1.1 200 0.12 secs: 10261 bytes ==> GET /home-decor/books-music.html
HTTP/1.1 200 0.12 secs: 10818 bytes ==> GET /home-decor/bed-bath.html
HTTP/1.1 200 0.12 secs: 11349 bytes ==> GET /home-decor/electronics.html
HTTP/1.1 200 0.13 secs: 10570 bytes ==> GET /home-decor/decorative-accents.html
HTTP/1.1 200 0.12 secs: 9976 bytes ==> GET /sale/women.html
HTTP/1.1 200 0.14 secs: 10168 bytes ==> GET /sale/men.html
HTTP/1.1 200 0.13 secs: 9818 bytes ==> GET /sale/accessories.html
HTTP/1.1 200 0.12 secs: 9744 bytes ==> GET /sale/home-decor.html
HTTP/1.1 200 0.11 secs: 8340 bytes ==> GET /women.html
HTTP/1.1 200 0.13 secs: 10267 bytes ==> GET /men/blazers.html
HTTP/1.1 200 0.10 secs: 8357 bytes ==> GET /men.html
HTTP/1.1 200 0.11 secs: 8541 bytes ==> GET /accessories.html
HTTP/1.1 200 0.12 secs: 8373 bytes ==> GET /home-decor.html
HTTP/1.1 200 0.14 secs: 11003 bytes ==> GET /sale.html
HTTP/1.1 200 0.14 secs: 10965 bytes ==> GET /vip.html
HTTP/1.1 200 0.20 secs: 11353 bytes ==> GET /aviator-sunglasses.html
HTTP/1.1 200 0.22 secs: 11126 bytes ==> GET /rolls-travel-wallet.html
HTTP/1.1 200 0.19 secs: 10641 bytes ==> GET /roller-suitcase.html
HTTP/1.1 200 0.21 secs: 10422 bytes ==> GET /body-wash-with-lemon-flower-extract-and-aloe-vera.html
HTTP/1.1 200 0.23 secs: 15068 bytes ==> GET /french-cuff-cotton-twill-oxford-611.html
criar o arquivo warm-cache.sh dar a permissão chmod +x nele, após isso instalar apt-get install siege && apt-get install libxml-xpath-perl . Para executar o warm basta passar assim: ./warm-cache.sh www.seushop.com.br/sitemap.xml (admin magento em: catagolo>google sitemap/criar sitemap)
#!/bin/bash
# Nexcess.net Turpentine Extension for Magento
# Copyright (C) 2012 Nexcess.net L.L.C.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
SITEMAP_URL="$1"
TMP_URL_FILE="/tmp/urls_$(cat /proc/sys/kernel/random/uuid).txt"
PROCS="${PROCS-$(grep processor /proc/cpuinfo | wc -l)}"
echo '<root/>' | xpath -e '*' &>/dev/null
if [ $? -eq 2 ]; then
XPATH_BIN='xpath'
else
XPATH_BIN='xpath -e'
fi
if [ -z "$SITEMAP_URL" ]; then
cat <<EOF
Usage: $0 <sitemap URL>
Warm Magento's cache by visiting the URLs in Magento's sitemap
Example:
$0 http://example.com/magento/sitemap.xml
EOF
exit 1
fi
echo "Getting URLs from sitemap..."
curl -ks "$SITEMAP_URL" | \
$XPATH_BIN '/urlset/url/loc/text()' 2>/dev/null | \
sed -r 's~http(s)?:~\nhttp\1:~g' | \
grep -vE '^\s*$' > "$TMP_URL_FILE"
echo "Warming $(cat $TMP_URL_FILE | wc -l) URLs using $PROCS processes..."
cat "$TMP_URL_FILE" | \
xargs -P "$PROCS" -r -n 1 -- \
siege -b -v -c 1 -r once 2>/dev/null | \
sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | \
grep -E '^HTTP'
cat "$TMP_URL_FILE" | \
xargs -P "$PROCS" -r -n 1 -- \
siege -H 'Accept-Encoding: gzip' -b -v -c 1 -r once 2>/dev/null | \
sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | \
grep -E '^HTTP'
rm -f "$TMP_URL_FILE"
@diegoborba
Copy link

Deivison,
Teria algum substituto para AWS?
apt-get install siege && apt-get install libxml-xpath-perl

Abs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment