Hi,
I've just moved to Authcache from using Boost (commerce site) and I was wondering if there is a way to warm up the Authcache with a wget like I was able to do with Boost?
This worked like a charm with Boost but no joy with Authcache :(
wget --quiet https://www.example.com/sitemap.xml --output-document - | egrep -o "https://www.example.com[^<]+" | wget -q --delete-after -i -
any ideas please?

Comments

znerol’s picture

Status: Active » Closed (duplicate)
Anonymous’s picture

I put together a couple of shell scripts that use wget & an XML sitemap created by the XML Sitemap module to crawl & cache Authcache pages for both anonymous & authenticated users. I have an account I created (named 'authentic') specifically to work with the authenticated user script. I run them daily from cron. This site only uses https, so to get authenticated page cache for http you would need to also hit those pages from http. In addition, if you have multiple combinations of user roles, you will need to do this for each combination to get pages cached for them (this is the way Authcache prefixes cached pages with a unique id for each combination of roles).

For anonymous users:

#!/bin/sh

export DISPLAY=:0

/usr/local/bin/wget -q https://example.com/sitemap.xml --no-cache -O - | egrep -o "https://example.com[^<]+" | /usr/local/bin/wget --header "Cookie: has_js=1" -U "cachewarmer" -q -i - -O /dev/null --wait 1

For authenticated users:

#!/bin/sh

export DISPLAY=:0

site=https://example.com/
name=authentic
pass=<password>
cookies=/var/www/example/example_com-cron-cookies.txt

touch /var/www/example/example_com-ba-cookies.txt
touch /var/www/example/example_com-cron-cookies.txt
chmod 0600 /var/www/example/example_com-ba-cookies.txt
chmod 0600 /var/www/example/example_com-cron-cookies.txt

/usr/local/bin/wget -O /dev/null --save-cookies /var/www/example/example_com-ba-cookies.txt --keep-session-cookies --load-cookies $cookies "${site}user"
/usr/local/bin/wget --keep-session-cookies --save-cookies $cookies --load-cookies $cookies -O /dev/null \
        --post-data="name=$name&pass=$pass&op=Log%20in&form_id=user_login" \
        "${site}user"
		
sess1=$(grep SSESS $cookies | awk -F '\t' '{ print $6}')
sess2=$(grep SSESS $cookies | awk -F '\t' '{ print $7}')
cookieheader=$(print "Cookie: has_js=1;$sess1=$sess2")

/usr/local/bin/wget -q --keep-session-cookies --save-cookies $cookies --load-cookies $cookies https://example.com/sitemap.xml --no-cache -O - | egrep -o "https://example.com[^<]+" | /usr/local/bin/wget --header "$cookieheader" -U "cachewarmer" -q -i - -O /dev/null --wait 1

I hope this will help somebody. Perhaps a script like this can be incorporated into Authcache?