View Full Version : [ubuntu] squid cache server

mohammad alsharqi
August 24th, 2012, 07:02 PM
hello everybody
i'd installed squid server on ubuntu to caching & fastest the browse

but my squid configuration may be incorrect so there is no request from cache but the site had cached, i'd check the access.log but every site was tcp-miss

what is the best conf.. of squid.conf to cache sites


August 24th, 2012, 11:26 PM
Have a look here and hopefully it will help you as much as it helped me.


On the Server.......

1.Installing the proxy
To install Squid type the following command in a terminal:

sudo aptitude install squid

2.Configuring the proxy
Configuration of Squid is done by editing the following file: /etc/squid/squid.conf
To edit this file, type Alt+F2 and enter the following command:

gksu gedit /etc/squid/squid.conf

2.1.Naming the proxy
Its important that Squid knows the name of the machine. To do this, locate the line "visible_hostname".
For example, if the machine is called "ubuntu" insert:

visible_hostname ubuntu

2.2 Choosing the Port
By default, the proxy server will use port 3128. To choose another port, locate the line:

http_port 3128

and change the port number, for example:

http_port 3177

2.3.Choosing the interface
By default the proxy server will listen on all interfaces. For security reasons, its better to put it on your local network only. For example, if the network card connected to your LAN has IP, change the line:


2.4. Setting access rights and priorities
By default, nobody else is allowed to connect to the proxy server. A list of permissions must be created.

For example, we will define a group encompassing the local network.

Find the line beginning with acl localhost...
At the end of the section, add:

acl localnet src

2.5. Authorizing access to group
Now that the group is defined, we will authorise it to use the proxy.
*** NOTE WELL ***
Locate the line :
http_access allow ... and add above "http_access deny all"

http_access allow localnet

2.6. Allow the use non-standard ports
By default, Squid allows HTTP traffic only on specific ports (e.g. 80). This can cause problems on websites using other ports.

For example, http://toto.com:81/images/titi.png will be blocked by Squid

To avoid this deadlock, find the line: http_access deny! Safe_ports and the edit it to: # http_access deny! Safe_ports
# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid3 100 16 256


August 25th, 2012, 05:57 AM
At best squid typically caches only 20-30% of the remote content, mostly graphics. If you see entries in /var/log/squid/access.log, then the cache is probably running as expected.

Try repeatedly visiting the same site and see whether anything is cached. If you use this site for testing, you should see objects like the smilies and other icons be cached. None of the message content is likely to be cached since the site is dynamic.

Also some sites will use HTTP headers to prevent caching their content. Streaming video sites are a common example of this.

mohammad alsharqi
August 25th, 2012, 10:24 PM
thanks alot drdos2006 for ur help

SeijiSensei this is access.log when i browse yahoo.com

1345929775.248 2596 TCP_MISS/200 66952 GET http://www.yahoo.com/ - DIRECT/ text/html
1345929776.123 1427 TCP_MISS/200 6004 GET http://l1.yimg.com/nn/fp/rsz/images/082412/pushup_sm_1345844497.jpg - DIRECT/ image/jpeg
1345929776.156 1459 TCP_MISS/200 6119 GET http://l1.yimg.com/nn/fp/rsz/images/082512/1air-ipad_sm_1345911256.jpg - DIRECT/ image/jpeg
1345929776.368 1468 TCP_MISS/200 3749 GET http://l.yimg.com/dh/ap/default/120824/rapper1_vmsm.jpg - DIRECT/ image/jpeg
1345929776.438 1547 TCP_MISS/200 8896 GET http://l.yimg.com/nn/fp/rsz/images/082412/squid1_ac_1345844611.jpg - DIRECT/ image/jpeg
1345929776.517 1617 TCP_MISS/200 14899 GET http://l.yimg.com/dh/ap/default/120824/hamster1.jpg - DIRECT/ image/jpeg
1345929777.346 2035 TCP_MISS/200 417 GET http://b.scorecardresearch.com/p? - DIRECT/ image/gif
1345929777.411 2018 TCP_MISS/200 492 GET http://us.bc.yahoo.com/b? - DIRECT/ image/gif
1345929788.981 2540 TCP_MISS/200 80031 GET http://l1.yimg.com/nn/fp/rsz/images/082412/pushup_uni_1345844497.jpg - DIRECT/ image/jpeg
1345929798.374 1934 TCP_MISS/200 18363 GET http://l1.yimg.com/dh/ap/default/120824/bride_uni.jpg - DIRECT/ image/jpeg

and this for facebook

1345929828.414 320 TCP_MISS/000 0 GET http://www.facebook.com/ - DIRECT/ -
1345929829.980 1320 TCP_MISS/301 400 GET http://facebook.com/ - DIRECT/ text/html
1345929832.295 2308 TCP_MISS/200 12404 GET http://www.facebook.com/ - DIRECT/ text/html
1345929834.106 1726 TCP_MISS/302 649 GET http://secure-us.imrworldwide.com/cgi-bin/m? - DIRECT/ text/html
1345929837.504 3389 TCP_MISS/200 519 GET http://www.facebook.com/brandlift.php? - DIRECT/ image/gif