domingo, 21 de abril de 2013

Making squid cache your downloads (android apk or anything you want)

Squid has some patterns that avoid caching, like when something is a query to a search engine or you are calling a cgi, ... this can avoid caching certain things that you may like to have cached, like for example the apks you download from google play, but of course you can make it cache them if you want. First just a note for people wanting to add transparent proxy to squid, at squid you should put the listening http port on transparent mode (or intercept on recent squids), something like: http_port 3128 transparent And then you must take to squid the traffic you want it to process, this is typically done using iptables with something like this: iptables -I PREROUTING -i wifi0 -s my_android_ip -p tcp --dport 80 -m addrtype ! --dst-type LOCAL -j REDIRECT --to-port 3128 With this two things done you should have the traffic you want being processed by your squid and you should be able to see it at /var/log/squid/access.log, but this doesn't mean it is caching what you want it to cache, for that we should find something that identifies the things we want to cache, like the url, for example, I chose this for google play apk downloads: acl market url_regex http://[^/]*\.android\.clients\.google\.com And then we tell squid that we want that cached: cache allow market That should make it, but I recommend you add also at least this couple of lines if you don't have them already, these are the lines to blame for not caching everything, but should be on your config anyway: acl QUERY urlpath_regex cgi-bin \? cache deny QUERY And that's it. I'll try to write how to extract that apk from the cache in a while, see you! ;-)

1 comentario:

Juanjo (Cheche) dijo...

would it work better this line?

acl market rep_mime_type application/