LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How does transparent cache works? (https://www.linuxquestions.org/questions/linux-newbie-8/how-does-transparent-cache-works-676800/)

landysaccount 10-16-2008 08:46 AM

How does transparent cache works?
 
Hello.

I would like to know how exactly does Squid does its transparent caching:

What I understand it does is:
When a user in a lan accesses a website, squid receives the request as a server from the browser (client) and as a client request the website from the server the website is hosted on. Then, receives the website as a client from the server and serves the web page to the browser as the a server saving on disk the served page. Now, when another user on the lan request the same page, squid serves it from its cache instead of requesting it again from the internet and as a result saving bandwidth. Is this correct?

I have a transparent cache installed but, I don't think is working that way. I tested by going to lets say www.bestbuy.com from one pc and then from another going to the same site to see if that page got cached but instead it requested from the actual server the page is hosted in.

I ran iptables -L -vn --line-numbers to see how many packets were forwarded where and I got this:

Squid server running in 192.168.3.100 on eth2 of the router
Lan is in 192.168.2.0/24 on eth1 or router
Internet is on eth0


11 30 1386 ACCEPT tcp -- eth1 eth2 192.168.2.0/24 192.168.3.100 tcp spts:1024:65535 dpt:3128 state NEW

and..

56 31 1395 ACCEPT tcp -- eth2 eth0 192.168.3.0/24 0.0.0.0/0 tcp spts:1024:65535 dpt:80 state NEW

By looking at that I noticed that the same requests are being downloaded from the internet. Please let me know if this is correct or not.

Thank you.

marozsas 10-16-2008 11:54 AM

yes, it is the general idea. (besides transparent means you don't need to specify a proxy address/port in browser config - transparent means the browser will use the default gateway address and the proxy running at the gateway will intercept request for port 80/http)

Anyway, the problem is "when another user on the lan request the same page".
Nodays, every site use cookies that are embbebed in the url, so access for the same site from different users may lead to different url to the site, and it is not cached.

Even so, a request is made just to check what is the current version of the page and if it is obsolete, a new page is reloaded from the site.

Bandwidth you generally save, comes from images, backgrounds and other static elements in the page. Sites that make intensive use of ajax and other dynamic elements may have small benefit from cached pages.

Squid has a "Squid Cache analysis" tool (if I am not wrong it is cachemgr.cgi - i am not sure) that can help you to setup your cache by specifying sizes and types of objects it will put in the cache.

I think iptables is not the best tool to debug your squid/cache access.

landysaccount 10-16-2008 01:21 PM

Thank you very much marozsas. I was somewhat worried I didn't have squid working properly. I will read about cachemgr so, I can put it to work.


All times are GMT -5. The time now is 12:51 PM.