[squid-users] Youtube Caching

From: Khemara Lyn <lin.kh_at_wicam.com.kh>
Date: Sun, 25 Apr 2010 10:38:19 +0700

Dear All,

I know this topic have been around every now and then; but i'm desperate
now in finding any fix.

I tried the configuration as mentioned in this page:

"Caching YouTube Content"
http://wiki.squid-cache.org/ConfigExamples/DynamicContent/YouTube?highlight=%28ConfigExamples%2FIntercept%29|%28ConfigExamples%2FAuthenticate%29|%28ConfigExamples%2FChat%29|%28ConfigExamples%2FStreams%29|%28ConfigExamples%2FReverse%29|%28ConfigExamples%2FStrange%29

But encountered this message in the access.log:

1272165634.722 0 202.79.24.34 TCP_MEM_HIT/302 784 GET
http://v11.nonxt4.c.youtube.com/videoplayback? - NONE/- -

It says TCP_MEM_HIT right at the first time the page is loaded. However,
the YouTube screen on the browser would say "An error occurred, please
try again later".

Please, anyone has any fix to this? Or do i need to apply the patch
given at the bottom of the page?

I am running squid-2.7-stable7 on CentOS with the squid.conf file as below:

#####
########### Port Config
http_port 127.0.0.1:3128
http_port 192.168.24.26:3128 transparent
icp_port 3130

########### WCCP2 Config
wccp2_router 192.168.24.25
wccp2_address 192.168.24.26
wccp2_forwarding_method 1
wccp2_return_method 1
wccp2_service standard 0 password=w1c4m_cp

########### Performance Related Config
forwarded_for transparent
half_closed_clients off
persistent_request_timeout 2 minutes
max_filedescriptors 0
max_open_disk_fds 0
relaxed_header_parser on
reload_into_ims on
quick_abort_min 0 KB
quick_abort_max 0 KB
client_lifetime 15 minutes
read_timeout 5 minutes
request_timeout 1 minutes
extension_methods NICK
ie_refresh on

########### Cache Config
##
http://wiki.squid-cache.org/SquidFaq/SquidMemory#head-19e0cdaa6ea3ec4d6943291a3d18c3f003acdc45
cache_dir aufs /cache2 160000 32 256
cache_dir aufs /cache3 160000 32 256
cache_dir aufs /cache4 160000 32 256
cache_effective_user squid
cache_effective_group squid
# Defaults are 90% and 95%. If you have a large cache, 5% could be
hundreds of MB. If this is the case you may wish to set these numbers
closer together.
cache_swap_low 94
cache_swap_high 95
# cache_replacement_policy heap LFUDA
request_header_max_size 2048 KB
minimum_object_size 512 bytes
maximum_object_size 2 GB
negative_ttl 1 minutes
# when a URL fails the outage will only last this long:
negative_dns_ttl 1 second
## Allowing whitespace URL, Default: uri_whitespace DENY
uri_whitespace ALLOW
###########

acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_cachehost dst 192.168.24.26
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl Safe_ports port 80 # http

acl mptc_blocked dstdomain "/etc/squid/blocked-websites.txt"
acl localnet1 src 192.168.24.0/255.255.255.0
acl localnet2 src 192.168.25.0/255.255.2255.0

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access allow localhost
###
http_access deny to_cachehost
http_access deny mptc_blocked
deny_info ERR_SITE_BLOCKED mptc_blocked
http_access allow localnet1
http_access allow localnet2
###
http_access deny all
icp_access deny all

##### Config for YouTube:
acl youtube dstdomain .youtube.com
cache allow youtube

acl store_rewrite_list urlpath_regex
\/(get_video\?|videodownload\?|videoplayback.*id)
storeurl_access allow store_rewrite_list
storeurl_access deny all
storeurl_rewrite_program /etc/squid/storeurl.pl
storeurl_rewrite_children 1
storeurl_rewrite_concurrency 10
refresh_pattern (get_video\?|videoplayback\?|videodownload\?) 5259487
99999999% 5259487 override-expire ignore-reload
#####
hierarchy_stoplist cgi-bin ?
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320

acl shoutcast rep_header X-HTTP09-First-Line ^ICY.[0-9]
upgrade_http0.9 deny shoutcast
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
coredump_dir /var/log/squid
access_log /var/log/squid/access.log squid
access_log /var/log/squid/cache.log squid
#####

Any help would be much appreciated.

Thanks & regards,
Khem
Received on Sun Apr 25 2010 - 03:38:31 MDT

This archive was generated by hypermail 2.2.0 : Sun Apr 25 2010 - 12:00:05 MDT