LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-01-2012, 07:14 AM   #1
uk.engr
Member
 
Registered: Apr 2012
Posts: 131

Rep: Reputation: Disabled
Cache in Squid Server


Assalam o Alaikum!

I am facing problem in squid caching. In squid.conf:

cache_dir ufs /var/spool/squid 100 16 256
[root@test1 /]# squid -z
2012/06/01 07:23:05| WARNING cache_mem is larger than total disk cache space!
Or
[root@test1 /]# service squid restart
Stopping squid: 2012/06/01 07:23:39| WARNING cache_mem is larger than total disk cache space!
................ [ OK ]
Starting squid: . [ OK ]

[root@test1 /]# cat /proc/meminfo
MemTotal: 767248 kB
MemFree: 27172 kB
Buffers: 99604 kB
Cached: 343260 kB
SwapCached: 8 kB
Active: 322416 kB
Inactive: 342244 kB
Active(anon): 103316 kB
Inactive(anon): 122236 kB
Active(file): 219100 kB
Inactive(file): 220008 kB
Unevictable: 0 kB
Mlocked: 0 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 767248 kB
LowFree: 27172 kB
SwapTotal: 1507324 kB
SwapFree: 1507316 kB
Dirty: 1008 kB
Writeback: 0 kB
AnonPages: 221788 kB
Mapped: 73324 kB
Shmem: 3756 kB
Slab: 61592 kB
SReclaimable: 52992 kB
SUnreclaim: 8600 kB
KernelStack: 1760 kB
PageTables: 5688 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1890948 kB
Committed_AS: 1067352 kB
VmallocTotal: 237624 kB
VmallocUsed: 5916 kB
VmallocChunk: 223032 kB
HardwareCorrupted: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 4096 kB
DirectMap4k: 16320 kB
DirectMap4M: 770048 kB







Wht shud I do?

Many thanks!

Last edited by uk.engr; 06-01-2012 at 08:09 AM.
 
Old 06-01-2012, 04:29 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,882

Rep: Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608
Hi,

It looks like you have defined a cache_mem bigger than the cache_dir (that is 100MB in your case).
You can either ignore it (it's just a warning), or set cache_mem lower than 100MB

Regards
 
Old 06-02-2012, 02:09 AM   #3
uk.engr
Member
 
Registered: Apr 2012
Posts: 131

Original Poster
Rep: Reputation: Disabled
Thanks for your reply. where i can find cache_mem? I mean how can I change this parameter? I have one more question how can I verify cache webs? I mean whether it is taking web from my cache or from internet?

[root@Zohaib zohaib_shaikh]# tail -f /var/log/squid/access.log
1338567636.688 763 192.168.1.111 TCP_MISS/200 1138 GET http://us.mg5.mail.yahoo.com/ws/mail/v2.0/formrpc? - DIRECT/183.177.93.20 application/json
1338567656.143 28770 192.168.1.111 TCP_MISS/200 399 GET http://prod1.rest-notify.msg.yahoo.c...annel/uk.engr? - DIRECT/67.195.186.237 application/json
1338567677.176 312770 192.168.1.111 TCP_MISS/200 1535 CONNECT mail.google.com:443 - DIRECT/74.125.232.117 -

Its look like it is taking webs from internet not from cache??
 
Old 06-02-2012, 03:08 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,882

Rep: Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608
Hi,

Quote:
where i can find cache_mem? I mean how can I change this parameter?
There should be a "cache_mem" option in squid.conf


Quote:
I have one more question how can I verify cache webs? I mean whether it is taking web from my cache or from internet?
Looking at access_log:
When you see a TCP_MISS it means that the object was not cached.
A TCP_HIT means that the object was fetched from cache. For a better explanation see this

Regards
 
Old 06-02-2012, 03:43 AM   #5
uk.engr
Member
 
Registered: Apr 2012
Posts: 131

Original Poster
Rep: Reputation: Disabled
Thanks. I am unable to find cache_mem option in squid.conf. I have attached my squid.conf in txt format. Kindly see this. How can I trouble shoot the problem of TCP_MISS? When I repeatedly open same webs it gives same message of TCP_MISS.
Attached Files
File Type: txt squid.txt (2.5 KB, 506 views)
 
Old 06-02-2012, 04:45 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,882

Rep: Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608
Quote:
I am unable to find cache_mem option in squid.conf. I have attached my squid.conf in txt format.
Indeed there is no cache_mem option. Doh, add it and use something like:
Code:
cache_mem 32 MB
so it stops complaining.


Quote:
How can I trouble shoot the problem of TCP_MISS? When I repeatedly open same webs it gives same message of TCP_MISS.
If it's a first time squid installation, you should have run:
Code:
squid -z
prior anything else, so squid could create it's cache directory structure (under /var/spool/squid in your case).
Note that this is done only once, before squid starts for the 1st time. Maybe you don't have a correct cache_dir and that's the reason for squid complaining about cache_mem.
 
Old 06-05-2012, 10:09 AM   #7
uk.engr
Member
 
Registered: Apr 2012
Posts: 131

Original Poster
Rep: Reputation: Disabled
Thanks. Dear, I tried cache_mem 32 MB, it works, now warning does not appears. This problem is resolved.

Now I am unable to resolve TCP_MISS problem. I have also used squid -z its output is:

[root@Zohaib zohaib_shaikh]# service squid stop
Stopping squid: ................ [ OK ]
[root@Zohaib zohaib_shaikh]# squid -z
2012/06/05 18:32:52| Creating Swap Directories
2012/06/05 18:32:52| /var/spool/squid exists
2012/06/05 18:32:52| /var/spool/squid/00 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/00
2012/06/05 18:32:52| /var/spool/squid/01 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/01
2012/06/05 18:32:52| /var/spool/squid/02 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/02
2012/06/05 18:32:52| /var/spool/squid/03 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/03
2012/06/05 18:32:52| /var/spool/squid/04 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/04
2012/06/05 18:32:52| /var/spool/squid/05 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/05
2012/06/05 18:32:52| /var/spool/squid/06 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/06
2012/06/05 18:32:52| /var/spool/squid/07 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/07
2012/06/05 18:32:52| /var/spool/squid/08 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/08
2012/06/05 18:32:52| /var/spool/squid/09 exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/09
2012/06/05 18:32:52| /var/spool/squid/0A exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/0A
2012/06/05 18:32:52| /var/spool/squid/0B exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/0B
2012/06/05 18:32:52| /var/spool/squid/0C exists
2012/06/05 18:32:52| Making directories in /var/spool/squid/0C

After restarting squid's service and accessing webs we have following log:


[root@Zohaib zohaib_shaikh]# tail -f /var/log/squid/access.log
1338901168.271 1864 192.168.1.109 TCP_MISS/200 1137 GET http://us.mg5.mail.yahoo.com/ws/mail/v2.0/formrpc? - DIRECT/183.177.93.20 application/json
1338901178.432 274105 192.168.1.109 TCP_MISS/200 2570 CONNECT mail.google.com:443 - DIRECT/173.194.35.117 -
1338901285.974 120000 192.168.1.109 TCP_MISS/000 0 GET http://prod2.rest-notify.msg.yahoo.c...annel/uk.engr? - DIRECT/216.155.195.253 -
1338901318.098 310000 192.168.1.109 TCP_MISS/200 2026 CONNECT mail.google.com:443 - DIRECT/173.194.35.117 -

Means no cacheing? How can we fix this problem?
 
Old 06-05-2012, 04:09 PM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,882

Rep: Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608
Hi,

If you want to test squid caching, you should visit the same URL several times and from the same or different systems/browsers and see what you get.
The 1st time you'll get a TCP_MISS, but after that you should start getting get TCP_HITs

Regards
 
Old 06-19-2012, 03:01 AM   #9
uk.engr
Member
 
Registered: Apr 2012
Posts: 131

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
If you want to test squid caching, you should visit the same URL several times and from the same or different systems/browsers and see what you get.
The 1st time you'll get a TCP_MISS, but after that you should start getting get TCP_HITs

Yes I tried the same but every time I got TCP_MISS so please any solution?
 
Old 06-19-2012, 05:39 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,882

Rep: Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608
Quote:
Originally Posted by uk.engr View Post
Yes I tried the same but every time I got TCP_MISS so please any solution?
Are you visiting dynamic pages? Try to visit a static page, like http://www.squid-cache.org for example and see what you get
 
Old 06-19-2012, 05:56 AM   #11
uk.engr
Member
 
Registered: Apr 2012
Posts: 131

Original Poster
Rep: Reputation: Disabled
Now I get following logs

First time:

1340100083.871 499 192.168.1.117 TCP_MISS/200 1870 GET http://www.squid-cache.org/favicon.ico - DIRECT/198.186.193.234 image/x-icon
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2nd and 3rd time
1340100099.589 1054 192.168.1.117 TCP_REFRESH_UNMODIFIED/304 531 GET http://www.squid-cache.org/ - DIRECT/198.186.193.234 -


Still not cacheing.
 
Old 06-19-2012, 07:14 AM   #12
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,882

Rep: Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608Reputation: 1608
The above 2 lines mean nothing. You should hit the site and watch squid access.log for the whole time. There should be many objects (like images etc) logged.
Then use another browser, hit the same site again and watch what happens with these objects. See for example the following snippets for another site:
Quote:
1st browser
19/Jun/2012:13:58:26 +0300 24 192.168.0.77 TCP_MISS/200 1187 GET http://www.linuxtoday.com/icom_inclu...login-itbe.png - HIER_DIRECT/www.linuxtoday.com image/png
19/Jun/2012:13:58:26 +0300 31 192.168.0.77 TCP_MISS/200 3113 GET http://www.linuxtoday.com/icom_inclu.../logo-itbe.png - HIER_DIRECT/www.linuxtoday.com image/png
19/Jun/2012:13:58:26 +0300 12 192.168.0.77 TCP_MISS/200 2295 GET http://www.linuxtoday.com/icom_inclu...randingcode.js - HIER_DIRECT/www.linuxtoday.com
application/java$
19/Jun/2012:13:58:26 +0300 16 192.168.0.77 TCP_MISS/200 1456 GET http://www.linuxtoday.com/icom_inclu...ister-itbe.png - HIER_DIRECT/www.linuxtoday.com image/png
19/Jun/2012:13:58:26 +0300 11 192.168.0.77 TCP_MISS/200 1046 GET http://www.linuxtoday.com/icom_inclu...ogout-itbe.png - HIER_DIRECT/www.linuxtoday.com image/png
19/Jun/2012:13:58:26 +0300 13 192.168.0.77 TCP_MISS/200 2240 GET http://www.linuxtoday.com/icom_inclu...-developer.png - HIER_DIRECT/www.linuxtoday.com image/png
19/Jun/2012:13:58:26 +0300 12 192.168.0.77 TCP_MISS/200 1261 GET http://www.linuxtoday.com/icom_inclu.../login-dev.png - HIER_DIRECT/www.linuxtoday.com image/png
19/Jun/2012:13:58:26 +0300 13 192.168.0.77 TCP_MISS/200 1552 GET http://www.linuxtoday.com/icom_inclu...gister-dev.png - HIER_DIRECT/www.linuxtoday.com image/png
19/Jun/2012:13:58:26 +0300 12 192.168.0.77 TCP_MISS/200 1153 GET http://www.linuxtoday.com/icom_inclu...logout-dev.png - HIER_DIRECT/www.linuxtoday.com image/png
19/Jun/2012:13:58:26 +0300 12 192.168.0.77 TCP_MISS/200 2249 GET http://www.linuxtoday.com/icom_inclu...-developer.png - HIER_DIRECT/www.linuxtoday.com image/png
19/Jun/2012:13:58:26 +0300 2927 192.168.0.77 TCP_MISS/200 16060 GET http://www.linuxtoday.com/ - HIER_DIRECT/www.linuxtoday.com text/html
<snip>
2nd browser:
19/Jun/2012:13:59:21 +0300 0 192.168.0.77 TCP_MEM_HIT/200 3120 GET http://www.linuxtoday.com/icom_inclu.../logo-itbe.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 0 192.168.0.77 TCP_MEM_HIT/200 1194 GET http://www.linuxtoday.com/icom_inclu...login-itbe.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 1 192.168.0.77 TCP_MEM_HIT/200 1463 GET http://www.linuxtoday.com/icom_inclu...ister-itbe.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 0 192.168.0.77 TCP_MEM_HIT/200 1053 GET http://www.linuxtoday.com/icom_inclu...ogout-itbe.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 0 192.168.0.77 TCP_MEM_HIT/200 2247 GET http://www.linuxtoday.com/icom_inclu...-developer.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 0 192.168.0.77 TCP_MEM_HIT/200 1268 GET http://www.linuxtoday.com/icom_inclu.../login-dev.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 0 192.168.0.77 TCP_MEM_HIT/200 1559 GET http://www.linuxtoday.com/icom_inclu...gister-dev.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 0 192.168.0.77 TCP_MEM_HIT/200 1160 GET http://www.linuxtoday.com/icom_inclu...logout-dev.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 1 192.168.0.77 TCP_MEM_HIT/200 2256 GET http://www.linuxtoday.com/icom_inclu...-developer.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 1 192.168.0.77 TCP_MEM_HIT/200 3280 GET http://www.linuxtoday.com/img/linuxtd_logo.png - HIER_NONE/- image/png
19/Jun/2012:13:59:21 +0300 650 192.168.0.77 TCP_MISS/200 16060 GET http://www.linuxtoday.com/ - HIER_DIRECT/www.linuxtoday.com text/html
19/Jun/2012:13:59:21 +0300 0 192.168.0.77 TCP_MEM_HIT/200 1626 GET http://www.linuxtoday.com/icom_inclu.../jw_netsol.gif - HIER_NONE/- image/gif
19/Jun/2012:13:59:21 +0300 13 192.168.0.77 TCP_MISS/200 2148 GET http://www.linuxtoday.com/icom_inclu...randingcode.js - HIER_DIRECT/www.linuxtoday.com application/javascript
19/Jun/2012:13:59:21 +0300 31 192.168.0.77 TCP_MISS/200 10553 GET http://www.linuxtoday.com/icom_inclu.../scripts/ga.js - HIER_DIRECT/www.linuxtoday.com application/javascript
<snip>
As you see static content like images is cached, while other objects are not
 
Old 06-19-2012, 07:51 AM   #13
uk.engr
Member
 
Registered: Apr 2012
Posts: 131

Original Poster
Rep: Reputation: Disabled
Yes dear, i understand now. It cacheing only static things. I got TCP_HIT. thanks dear.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Browser Cache vs Caching Server (Squid) phpinfo Linux - Networking 2 12-15-2009 04:49 AM
Using Active directory Authentication of parent non-squid cache to child squid cache espiya7 Linux - Server 0 05-05-2009 09:04 AM
Squid proxy or cache server? jonette20 Linux - Newbie 2 08-07-2007 09:27 AM
squid keeps stopping on my Cache Server rickyinman Slackware 1 04-05-2007 05:29 PM
Problem w/Squid Cache server @ bootup eroica Linux - Software 0 06-08-2004 02:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration