#!/bin/sh # Example of how to warm Drupal authcache. # See https://drupal.org/node/118759 # or http://stackoverflow.com/questions/4272770/wget-with-authentication set -x set -e site=http://YOUR-SITE.COM name=YOUR_USERNAME pass=YOUR_PASSWORD cookies=/tmp/warm-cache-cookies.$$.txt srcdir=`dirname $0` srcdir=`cd $srcdir; pwd` # Log in and save the session cookie wget --post-data "name=$name&pass=$pass&form_id=user_login" --keep-session-cookies --save-cookies $cookies $site/users/$name # Drupal seems to have set nocache to 1 at this point. # The authcache source code gives up if you have nocache set to 1, # but requires has_js to be set to 1. # There must be a tab between the name and the value. # I'm lazy, so cheat and hijack the existing nocache variable. sed -i 's/nocache/has_js/' $cookies # Finally, fetch those URLs. wget --load-cookies $cookies -i $srcdir/warm-cache-urls.txt -O /dev/null rm $cookies