Squid not caching
In my experience, the 3 most common reasons why Squid refuses to cache content are:
- Cache directory permissions, and you have taken care of that. Good :)
http_access, but it's not your case, because you are seeing
TCP_MISSlines in your access.log
refresh_pattern directive(s) control how Squid considers objects fresh or stale, particularly in relation to the way your browser makes the requests, and which cache control HTTP headers are exchanged.
refresh_pattern lines you have in your configuration are Squid's default lines. However, I just installed Squid on Ubuntu 2 weeks ago, and with those defaults, it caches almost nothing.
Squid's documentation about refresh_pattern should explain the meaning of each line, but I actually can't understand what that documentation means. And apparently I'm not alone :)
I would suggest you to add one or more of the following patterns and test specific files/URLs until you're satisfied. Example:
refresh_pattern -i \.(gif|png|jpg|jpeg|ico)$ 3600 90% 43200
With this one, you're telling Squid to consider all icons/pictures cacheable for at least 1 hour to a maximum of half a day. Your browser might send HTTP requests with particular cache headers that cause Squid to reply with a
TCP_MISS anyway. To force cached replies, even breaking client expectations, you can do this:
refresh_pattern -i \.(gif|png|jpg|jpeg|ico)$ 3600 90% 43200 override-expire ignore-no-cache ignore-no-store ignore-private
Same goes for bigger movie/audio/iso files:
refresh_pattern -i \.(mp[34g]|swf|wav|...)$ 43200 90% 432000
If anything else fails, use a mighty hammer :) but I do not recommend this:
refresh_pattern . 3600 80% 14400
with which you're telling Squid that it can cache everything for at least 1 hour. However, this will almost certainly break dynamic applications. Use it if the server you're trying to cache is mostly composed of static content.
Also, don't forget
maximum_object_size. By default, it's 20Mb. If the objects you're trying to cache are bigger than that, Squid won't cache them. I upped it 10x, to 200Mb. YMMV.
maximum_object_size 204800 KB
cache_peer line is incorrect, because it points to Apache. A
cache_peer in squid speak is another squid instance higher up in the cache hierarchy, that usually used to be an ISP cache server in the old days. Just remove that line.
And good luck :)
In your config you have missed this lines:
acl myhosts src 192.168.0.0/255.255.0.0 (your internal network/netmask) http_access allow myhosts
Your web server is not your cache_peer. Please, remove this line from your config file. Squid has for interoperability between caches another type of protocol (ICP), which apache don't know.