Squid For Youtube Cache
Squid For Youtube Cache
com/2012/08/13/youtube-
caching-with-squid-nginx/
Updated Version of squid which cache youtube and many other contents. read following
https://aacable.wordpress.com/2012/01/19/youtube-caching-with-squid-2-7-using-storeurl-pl/
In most part of the world, bandwidth is very expensive, therefore it is (in some scenarios) very useful to
Cache Youtube videos or any other flash videos, so if one of user downloads video / flash file , why again
the same user or other user can’t download the same file from the CACHE, why he sucking the internet
pipe for same content again n again?
Peoples on same LAN ,sometimes watch similar videos. If I put some youtube video link on
on FACEBOOK, TWITTER or likewise , and all my friend will watch that video and that particular video gets
viewed many times in few hours. Usually the videos are shared over facebook or other social networking
sites so the chances are high for multiple hits per popular videos for my LAN users / friends.
[syed.jahanzaib]
The chances, that another user will watch the same video, is really slim. if I search for something specific
on youtube, i get more then hundreds of search results for same video. What is the chance that another
user will search for the same thing, and will click on the same link / result? Youtube hosts more than 10
million videos. Which is too much to cache anyway. You need lot of space to cache videos. Also accordingly
you will be needing ultra modern fast hardware with tons of SPACE to handle such kind of cache giant.
anyhow Try it
AFAIK you are not supposed to cache youtube videos, youtube don’t like it. I don’t understand why.
Probably because their ranking mechanism relies on views, and possibly completed views, which wouldn’t
be measurable if the content was served from a local cache.
After unsuccessful struggling with storeurl.pl method , I was searching for alternate method to cache
youtube videos. Finally I found ruby base method using Nginx to cache YT. Using this method I was able to
cache all Youtube videos almost perfectly. (not 100%, but it works fine in most cases with some
modification.I am sure there will be some improvement in near future).
Updated: 24thth August, 2012
Thanks to Mr. Eliezer Croitoru & Mr.Christian Loth & others for there kind guidance.
1) Update Ubuntu
First install Ubuntu, After installation, configure its networking components, then update it by following
command
apt-get install update
Now install SSH server so that you can manage your server remotely using PUTTY or any other ssh tool.
nano /etc/squid/squid.conf
4) Install Nginx
touch /etc/nginx/nginx.rb
chmod 755 /etc/nginx/nginx.rb
nano /etc/nginx/nginx.rb
5) Install RUBY
What is RUBY?
Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has
an elegant syntax that is natural to read and easy to write. [syed.jahanzaib]
mkdir /cache1
chown proxy:proxy /cache1
chmod -R 777 /cache1
squid -z
Look at the below WAN utilization graph, it was taken while watching the clip which is not in cache
Now Look at the below WAN utilization graph, it was taken while watching the clip which is now in CACHE.
It will load first chunk from the cache, if the user keep watching the clip, it will load next chunk at the end
of first chunk, and will continue to do so.
e.g:
ls -lh /usr/local/www/nginx_cache/files
The above file shows the clip is in 360p quality, and the length of the clip is 5:54 Seconds.
itag=34 shows the video quality is 360p.
Credits: Thanks to Mr. Eliezer Croitoru & Mr.Christian Loth & others for there kind guidance.