Extract purging logic

The logic for making the HTTP request to purge a URL/hostname is a bit un-DRY at the moment.