Skip to content

Instantly share code, notes, and snippets.

View hernandesbsousa's full-sized avatar

Hernandes Benevides de Sousa hernandesbsousa

View GitHub Profile

How to purge ('ban') an entire domain in Varnish Cache 3

I thought I'd share this because it's taken me a couple of hours to work out and the documentation is not entirely clear.

Jump to answer

ban wtf?*

First of all, the purge method used to be called purge in Varnish 2.x but they renamed it to ban in 3.0. Confusingly there is also a new command called purge too! The new purge command is much less sophisticated than ban, as (AFAIK) it only purges exactly matched items, so basically one at a time.

If you do wish to use the new purge you need to have some specific VCL in place. See here

#!/usr/bin/env bash
apt-get -y update
apt-get -y upgrade
apt-get -y install git build-essential autoconf zlib1g-dev libssl-dev \
libreadline-dev libyaml-dev libcurl4-openssl-dev curl python-software-properties \
ruby1.9.1 ruby1.9.1-dev rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1
gem install chef ruby-shadow --no-ri --no-rdoc
#!/bin/bash
#
# Bash shell script for generating self-signed certs. Run this in a folder, as it
# generates a few files. Based on the following GIST Extract by Brad Landers:
# https://gist.github.com/bradland/1690807
#
# Additional alterations by: Hernandes B. de Sousa
# Date: 2013-10-04
#
@hernandesbsousa
hernandesbsousa / Category.sql
Last active December 20, 2015 07:09 — forked from ticean/Category.sql
Various Magento queries
SET @entityid = '3';
SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'varchar' AS 'type'
FROM catalog_category_entity e
JOIN catalog_category_entity_varchar eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
WHERE e.entity_id = @entityid
UNION
mkdir demo
cd demo
wget http://www.magentocommerce.com/downloads/assets/1.7.0.2/magento-1.7.0.2.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
tar -zxvf magento-1.7.0.2.tar.gz
tar -zxvf magento-sample-data-1.6.1.0.tar.gz
mv magento-sample-data-1.6.1.0/media/* magento/media/
mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
mv magento/* magento/.htaccess .
chmod o+w var var/.htaccess app/etc