福冨諭の福冨論

RSSリーダーではこちらをどうぞ→https://feeds.feedburner.com/fuktommy

Squidでニコニコ動画のキャッシュを試みた

ASR's Room NicoCache を読んで、 それ Squid でもできないかなと思ったので、 やってみました。

Squidは2.6と2.7で試しました。 設定ファイルはこんな感じ。 2.6は cache deny QUERY を無効にする必要があります。

--- squid.conf.default  2008-10-20 04:43:54.000000000 +0900
 +++ squid.conf  2008-11-17 00:38:16.000000000 +0900
 @@ -1780,6 +1780,7 @@
  #
  #Default:
  # cache_dir ufs /var/spool/squid 100 16 256
 +cache_dir ufs /var/spool/squid 50000 16 256
 
  #  TAG: store_dir_select_algorithm
  #      Set this to 'round-robin' as an alternative.
 @@ -1819,6 +1820,7 @@
  #
  #Default:
  # maximum_object_size 4096 KB
 +maximum_object_size 65536 KB
 
  #  TAG: cache_swap_low (percent, 0-100)
  #  TAG: cache_swap_high        (percent, 0-100)
 @@ -2128,6 +2130,7 @@
  #
  #Default:
  # strip_query_terms on
 +strip_query_terms off
 
  #  TAG: buffered_logs  on|off
  #      cache.log log file is written with stdio functions, and as such
 @@ -2367,7 +2370,7 @@
  #      Default is to allow all to be cached
  #We recommend you to use the following two lines.
  acl QUERY urlpath_regex cgi-bin \?
 -cache deny QUERY
 +#cache deny QUERY
 
  #  TAG: refresh_pattern
  #      usage: refresh_pattern [-i] regex min percent max [options]

Firefoxのプロキシ設定ファイルはこんな感じ。 localhost:8095禁断の壷です。

function FindProxyForURL(url, host) {
     if (dnsDomainIs(host, "2ch.net") ||
         dnsDomainIs(host, "bbspink.com") ||
         dnsDomainIs(host, "local.tubo.img")) {
         return "PROXY localhost:8095";
     } else if (shExpMatch(url, "http://*.nicovideo.jp/smile*")) {
         return  "PROXY localhost:3128";
     } else {
         return "DIRECT";
     }
 }

Original Article: http://blog.fuktommy.com/1226850591