RE: [squid-users] Caching youtube videos problem/ always getting TCP_MISS

From: Saurabh Agarwal <>
Date: Fri, 26 Nov 2010 15:23:10 +0530

Hi All

This is what I had to do for successfully caching youtube video. I tested with this URL

Please follow the instruction given on . Then I had these following lines in squid.conf. Also pasting below my

###Following refresh pattern and store url rewrite config was used

acl store_rewrite_list1 dstdomain
acl store_rewrite_list urlpath_regex \/(get_video\?|videodownload\?|videoplayback\?|watch\?)
#acl store_rewrite_list urlpath_regex \/(get_video\?|videodownload\?|videoplayback\?|watch\?|generate_204\?|docid=)
storeurl_access allow store_rewrite_list store_rewrite_list1
storeurl_access allow all
cache allow all
storeurl_rewrite_program /tmp/squid/
storeurl_rewrite_children 1
storeurl_rewrite_concurrency 10

#youtube's videos
#refresh_pattern -i (get_video\?|videoplayback\?|videodownload\?|watch\?|generate_204\?|docid=)$ 5259487 99999999% 5259487 ignore-no-cache override-lastmod override-expire ignore-reload negative-ttl=0
refresh_pattern -i (get_video\?|videoplayback\?|videodownload\?|watch\?) 5259487 99999999% 5259487 ignore-private ignore-no-cache override-expire ignore-reload negative-ttl=0

##squid.conf portion ends

##contents of
while (<>) {

    @X = split;
    $x = $X[0];
    $_ = $X[1];
    if (m/^http:(.*)\.youtube\.com\/videoplayback\?(.*)id=(.*?)&/) {
                print $x."" . $3 . "\n";
    }elsif (m/^http:(.*)\.youtube\.com\/generate_204\?(.*)id=(.*)/) {
                print $x."" . $3 . "\n";
    }elsif (m/^http:(.*)\.video\.google\.com\/(.*)docid=(.*?)&/) {
                print $x."" . $3 . "\n";
    } elsif (m/^http:\/\/(.*)\.youtube\.com\/get_video\?video_id=(.*)/) {
                print $x."" . $2 . "\n";
    } elsif (m/^http:(.*)\.youtube\.com\/watch.*v=(.*)&/) {
                print $x."" . $2 . "\n";
    } elsif (m/^http:(.*)\.youtube\.com\/watch.*v=(.*)$/) {
                print $x."" . $2 . "\n";
    } elsif (m/^http:(.*)\.youtube\.com\/get_video\?(.*)video_id=(.*?)&/) {
                print $x."" . $3 . "\n";
    } elsif (m/^http:\/\/74\.125(.*?)\/get_video\?video_id=(.*?)&origin=(.*?)\.youtube\.com /) {
                print $x."" . $2 . "\n";
    } else {
        print $x.$_ . "\n";
    } ends

Thank You.


-----Original Message-----
From: Saurabh Agarwal []
Sent: Friday, November 26, 2010 3:10 PM
To: Amos Jeffries
Subject: RE: [squid-users] Caching youtube videos problem/ always getting TCP_MISS

Hi Amos

It works fine now. Youtube videos are being cached. There was a mistake in refresh_pattern.


-----Original Message-----
From: Amos Jeffries []
Sent: Tuesday, November 23, 2010 4:47 PM
Subject: Re: [squid-users] Caching youtube videos problem/ always getting TCP_MISS

On 23/11/10 23:50, Saurabh Agarwal wrote:
> Thanks Amos.
> I fixed the channel id problem by fixing storeurl rewriter perl script but still the video/x-flv response is getting RELEASED in store.log instead of SWAPOUT. Can you please read below cache.log and suggest what is still going wrong? Now "Rewrote to" message prints the right transformed URL. After this store tries to look up for the "6B2E83D66FC215C27ECFBA432AB7B5F6" key which returns a TCP MISS for the same key lookup for 2nd and third tries as well. Then one hash entry gets inserted with another key for the same big URL with different hash key for 2nd and 3rd time as well. This new key is "04BE27CFF614A3315F5CEB008464C453". I have also pasted HTTP response header for video/x-flv content from cache.log. After this I see "Deferring starting swapping out" message in cache.log. Can you please suggest why it is not swapping out?
> I am pasting below a section of squid.conf file as well. After this is the cache.log output.

I'm thinking you don't want to ignore the last-modified header. It seems
to be usefully far in the past to cause caching for some period.
Ignoring it may cause the refresh_pattern to fail in extending the
storage time (99999999% of last-modified age).

Other than that I don't really know. I have not spent time working out
how to port storeurl* feature yet so don't know its internals well.

Please be using
   Current Stable Squid 2.7.STABLE9 or 3.1.9
   Beta testers wanted for
Received on Fri Nov 26 2010 - 09:53:21 MST

This archive was generated by hypermail 2.2.0 : Fri Nov 26 2010 - 12:00:02 MST