Syed Jahanzaib Personal Blog to Share Knowledge !

January 23, 2012

SQUID: Howto Exclude some sites & Exntension from CACHING


Howto Exclude Few Sites from Caching

========================================

To exclude your local domain sites / range from cache, use following


acl local_server dst 192.168.0.0/24 192.168.1.0/24
cache deny local_server

========================================

If you are using SQUID proxy server and you don’t want to cache few sites , use the following directives,

SQUID 3.x

acl hotmail dstdomain .hotmail.com
always_direct allow hotmail

.

.

Another method

acl NO-CACHE-SITES dstdomain "/etc/squid/not-to-cache-sites.txt"
no_cache deny NO-CACHE-SITES
acl sharing_server dst 10.0.0.1
cache deny sharing_server

Now create the file which will contains our sites list which we don’t want to cache.

touch /etc/squid/not-to-cache-sites.txt

and add  your desired web sites name in /etc/squid/not-to-cache-sites.txt
For example

nano /etc/squid/not-to-cache-sites.txt


and add following or your entries

bankalhabib.com
aacable.wordpress.com
wordpress.com
nae.com.pk
jang.com.pk

Now we have to reload squid.conf so changes may apply by following command

squid -k rec
OR
squid -k reconfigure

OR if squid3 use

squid3 -k rec

.

.

.

Howto Exclude Specific Extension from Caching

Similarly if you don’t want to cache *.FLV files , use the following directives

hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \? \.flv
no_cache deny QUERY


Now we have to reload squid.conf so changes may apply by following command

squid -k rec
OR
squid -k reconfigure

.

.

.

.

Regard's
Syed Jahanzaib

Advertisements

12 Comments »

  1. your website has very good material! congratulations!

    Like

    Comment by m4sk4r4 — January 23, 2012 @ 3:37 PM

  2. AOA sir,
    can you tell me how to use multiple live ip in my squid server for example,
    i have squidserver and 10 live ip and i want to allow my users to use different live ip for internet like this
    total live ip starting from 192.168.1.1 to 192.168.1.10
    total users ip starting from 192.168.1.11 to 192.168.1.20
    user 11 use my squid server and also use live ip 192.168.1.1 for internet. for example when i search http://www.whatismyipaddress.com on user 11 browser it should give me the live ip address 192.168.1.1.
    and when i search on user 12 to it should give me live ip address 192.168.1.2.

    please help me asap.
    Best Regards,
    muhammad nauman

    Like

    Comment by Muhamamd Nauman — February 29, 2012 @ 11:10 AM

    • Use TPROXY/SQUID if your users have PUBLIC Ips
      TPROXY will preserve user original public ip and will also perform cache facility.

      Like

      Comment by Syed Jahanzaib / Pinochio~:) — February 29, 2012 @ 12:01 PM

      • mere pas 8 pool ka dedicated ip hai but main chahta ye ho ke jab mere user internet per browsing kare main un ko kisi b ip se browsing kerwa sako.
        for example: dedicated ip 116.58.12.12 on linux eth0. and local ip 192.168.1.10 on eth1
        dedicated ip start from 116.58.12.12-116.58.12.16
        client ip start from 192.168.1.11-192.168.1.20.
        ab main chahta ye ho ke jab mera client 192.168.1.11 mere squid server ko use kare to uski traffic 116.58.12.12
        se bahir nikle.
        aour jab mere client ip change ho to uski request 116.58.12.13 se bahir nikle.
        isterha main jis ka b ip change kerna chaho change ho jaye.

        Like

        Comment by muhammad nauman — February 29, 2012 @ 1:04 PM

      • Hi, how make TPROXY/SQUID… not nat public ip’s

        Like

        Comment by Carlos Guzman — September 7, 2012 @ 3:58 AM

  3. Sir, first of all sorry if i ask a stupid question (i am new to squid).
    I just have two problems ( or my needs for squid) i hope you could easily solve them.

    1. I want to use a parent proxy in my squid proxy server. I am already using it in Mikrotik and it works good, but i want to use Squid + Mikrotik so i want to use parent proxy with Squid. I surfed a lot about it on internet and everywhere they say about using “cache_peer” command. But whenever i try to use this command i get this error:
    “cache_peer: command not found”
    So i want to resolve this problem please!!

    2. My second problem is regarding this post. I am trying to use the first command (i.e acl NO-CACHE-SITES dstdomain “/etc/squid/not-to-cache-sites.txt”) and my badluck, i get error, “acl:command not found”.

    Like

    Comment by Aftabftab Ahmed — December 5, 2012 @ 2:00 AM

  4. I am using a Parent Proxy. How to exclude Google.com in Squid so that it does not use Parent proxy to open google.com ?

    Like

    Comment by Aftabftab Ahmed — December 8, 2012 @ 4:57 PM

  5. Sir is file ki permision change nahi karni ……….hai…..

    Like

    Comment by waqar — July 25, 2013 @ 6:32 AM

  6. is it possible to cache ONLY specfic official channel videos of youtube on squid? I have configured Squid3.x proxy for dynamic contents (SSL) and now i want to cache ONLY official channels video. If its possible then help me to do that. i’ll really appreciate it. Thank you

    Like

    Comment by Umer Sarwar — October 17, 2013 @ 1:24 AM

  7. thanks for explain some ways not caching some webs.
    looks easier now

    Like

    Comment by Ma'el — November 26, 2013 @ 4:31 AM

  8. sir can you pl confirm how to exclude a site from mikrotik so that it served directly..????

    Like

    Comment by Bhanu — March 2, 2014 @ 7:59 AM


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: