Re: [squid-users] url_regex help

From: Guillaume Smet <guillaume.smet_at_gmail.com>
Date: Fri, 2 Jan 2009 22:19:01 +0100

On Fri, Jan 2, 2009 at 5:13 PM, Dean Weimer <dweimer_at_orscheln.com> wrote:
> Here's what I have, anyone have an idea where I went wrong
> I am Running Squid 3.0 Stable 9 on FreeBSD 6.2
> Acl NOCACHEPDF url_regex -i ^http://hostname.\*pdf$
> Acl NOCACHEXLS url_regex -i ^http://hostname.\*xls$
> No_cache deny NOCACHEPDF NOCACHEXLS
>
> I have used cat combined with awk and grep to check the pattern matching on the access logs with:
> Cat /usr/local/squid/var/logs/access.log | awk '{print $7}' | grep -e ^http://hostname.\*pdf$
> Cat /usr/local/squid/var/logs/access.log | awk '{print $7}' | grep -e ^http://hostname.\*xls$

The \ character before the * is only necessary to prevent your shell
from expanding the wildcard because you didn't use quotes to escape
your regexp.

In your Squid conf file, you just need:
acl NOCACHEPDF url_regex -i ^http://hostname.*pdf$
acl NOCACHEXLS url_regex -i ^http://hostname.*xls$

But if I were you, I'd use:
acl NOCACHEXLS url_regex -i ^http://hostname/.*\.xls$
acl NOCACHEPDF url_regex -i ^http://hostname/.*\.pdf$
which is more precise and more correct IMHO.

Or shorter:
acl NOCACHE url_regex -i ^http://hostname/.*\.(pdf|xls)$

-- 
Guillaume
Received on Fri Jan 02 2009 - 21:19:04 MST

This archive was generated by hypermail 2.2.0 : Sat Jan 03 2009 - 12:00:01 MST