acl AntiBaidu req_header User-Agent Baiduspider
http_access deny AntiBaidu
#Squid信息设置
visible_hostname www.cnprint.org
cache_mgr admin@cnprint.org
#squid使用的用户组和用户名
cache_effective_user nobody
cache_effective_group nobody
tcp_recv_bufsize 65535 bytes
client_persistent_connections off
server_persistent_connections on
half_closed_clients off
#单台使用,不使用该功能
icp_port 0
#设置Squid所能使用的内存共40MB,这个值因人而异,每次处理缓存大小为40MB,当缓存空间使用达到95%时新的内容将取代旧的而不直接添加到目录中,直到空间又下降到90%才停止这一活动
cache_mem 40 MB
cache_swap_low 90
cache_swap_high 95
#最大缓存文件大小,超过这个值则不缓存,这个值因人而异,maximum_object_size_in_memory #装入内存缓存的文件大小,这个值对Squid的性能影响比较大,因为默认值是8K,超过8K的文件都不装入内存,而实际应用中很多网页和图片等都超过 8KB, 个人认为如果缓存不装入内存而存在磁盘上,性能和apache直接读取磁盘文件没什么区别,甚至不如直接访问apache,现在设置成小于4兆的文件通通装入内存缓存.
maximum_object_size 4096 KB
minimum_object_size 0 KB
maximum_object_size_in_memory 4096 KB
ipcache_size 1024
ipcache_low 90
ipcache_high 95
cache_replacement_policy lru
memory_replacement_policy lru
#磁盘缓存的类型和目录,大小,一二级目录的设置,这里磁盘缓存大小是100MB,都是 16*256 级子目录
cache_dir ufs /usr/local/squid/var/cache 100 16 256
#这个设置是不记录store.log
cache_store_log none
#设置默认刷新规则
refresh_pattern -i ^ftp: 1440 20% 10080
refresh_pattern -i ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
#不要相信ETag 因为有gzip
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
#设置超时策略
forward_timeout 20 seconds
connect_timeout 15 seconds
read_timeout 3 minutes
request_timeout 1 minutes
persistent_request_timeout 15 seconds
client_lifetime 15 minutes
shutdown_lifetime 5 seconds
negative_ttl 10 seconds
#打开emulate_httpd_log选项,将使Squid仿照Aapche的日志格式
emulate_httpd_log on
#日志格式combined的设置
logformat combined %>a %ui %un [%tl] "%rm %ru HTTP/%rv" %Hs % #这里是设置pid和日志文件的位置,因人而异,同时日志格式是combined,awstats可以直接调用分析了
pid_filename /usr/local/squid/var/squid.pid
cache_log /usr/local/squid/var/logs/cache.log
access_log /usr/local/squid/var/logs/access.log combined
#设置不想缓存的目录或者文件类型
acl all src 0.0.0.0/0.0.0.0
acl QUERY urlpath_regex cgi-bin .php .cgi .avi .wmv .rm .ram .mpg .mpeg .zip .exe










