Exclude domains and paths from squid cache

→ Are you a new visitor? Please visit the page guidance for new visitors ←

Exclude domains and paths from squid cache

I’ve written some time ago an article showing you how to install squid and use it for reverse cache proxy and acceleration, however there are times when you do not want to have a certain urls or paths cached using squid, probably for debugging or similar. Normally you should have no issue with squid cache like you have with varnish which is more versed in caching pages, including dynamic php pages, then squid. Anyway in such cases you can exclude domains or paths from squid cache. In this article i’m going to show you two methods on how you can do this.

Excluding directly from squid config file

This is mostly used when there are little paths or domains that you wish to exclude. As such, you can just add the ACL rules directly in the squid.conf file like so:

Basically we create a rule for destinations domains and enlist the domains in one line with a space between, making sure the domains start with the first dot (.) for matching the www part of the domain.

In the same manner we can use this for paths, we just create a rule for the path we want, but using url_regex:

Exclude list of domains or paths from a text file

Now for cases when you have a lot of paths or domains, you can easily add all paths into a file and then include this file inside the ACL rule. I added two examples bellow showing you how you can do this for both domains and paths:

and the content of the file.txt would need to contain one domain per line in the following format:


The same for url_regex file, one regular expression per line.

So that wasn’t that hard, right? Let me know if you like it or if you need help with something else in your proxy settings.

That’s it for now, please share it and comment bellow if you have questions.

Request an article ←