Re: [squid-users] YouTube and other streaming media (caching)

From: Horacio Herrera Gonzalez <pokehorace_at_gmail.com>
Date: Mon, 9 Jun 2008 12:14:44 -0500

Hi Adrian, Ray and everyone...

Here is a little contribution for the store_url_rewrite script, this
part deals with youtube and google video (At least, it works for
now)...

NOTES:

1) This code is different because is based on the examples for the
url_rewrite_program
(http://wiki.squid-cache.org/SquidFaq/SquidRedirectors) and that way
was easier for me.

2) Warning! This code may match other sites not related to YT or GV.

3) I used "squid://" at the begining of the rewrited string to avoid
matching another rule, I know it's not standard and I'm still hoping
It doesn't cause any problems... Dear developers, please forgive my
insolence... :-)

--------------------
$|=1;
while (<>) {
  @X = split;
  $url = $X[0];
  $url =~ s@^http://(.*?)/get_video\?(.*)video_id=(.*?)&.*@squid://videos.youtube.INTERNAL/ID=$3@;
  $url =~ s@^http://(.*?)/get_video\?(.*)video_id=(.*?)$@squid://videos.youtube.INTERNAL/ID=$3@;
  $url =~ s@^http://(.*?)/videodownload\?(.*)docid=(.*?)$@squid://videos.google.INTERNAL/ID=$3@;
  $url =~ s@^http://(.*?)/videodownload\?(.*)docid=(.*?)&.*@squid://videos.google.INTERNAL/ID=$3@;
  print "$url\n";
}
--------------------

4) This is the relevant part of my squid.conf:

acl store_rewrite_list url_regex ^http://(.*?)/get_video\?
acl store_rewrite_list url_regex ^http://(.*?)/videodownload\?
cache allow store_rewrite_list

# Had to uncomment this again, because I couln'd login to google mail
using IE6 (firefox had no trouble):
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY

refresh_pattern ^http://(.*?)/get_video\? 10080 90% 999999
override-expire ignore-no-cache ignore-private
refresh_pattern ^http://(.*?)/videodownload\? 10080 90% 999999
override-expire ignore-no-cache ignore-private

storeurl_access allow store_rewrite_list
storeurl_access deny all

storeurl_rewrite_program /usr/local/bin/store_url_rewrite

--------------------

Regards,
Received on Mon Jun 09 2008 - 17:14:52 MDT

This archive was generated by hypermail 2.2.0 : Tue Jun 10 2008 - 12:00:03 MDT