Welcome! Log In Create A New Profile

Advanced

Re: nginx caching

July 19, 2009 06:56AM
On Sun, Jul 19, 2009 at 02:54:34AM -0700, Gabriel Ramuglia wrote:

> Hi,
>
> I've been using nginx for a while now to proxy flv videos via youtube,
> to good effect. However, the site that I'm accessing to proxy videos,
> I'm having problems being able to access their site in bulk, so I've
> decided to start caching things locally so as not to hit the remote
> server so often. I'm doing this in squid, and, for a variety of
> reasons, using the url_rewriter function to help out. My urls change
> every hour, but the video they refer to does not, so I have to use the
> rewriter to make sure the cache stays relevant.
>
> Now, the problem is, squid is using something like 60% of one core of
> cpu doing something like 200 megabit / s of bandwidth. This is on top
> of the fact that squid has to pass cache misses off to nginx, which is
> using another 20% or so (of one core, again) cpu use. Obviously if I
> could cut squid out of the equation this would be ideal.
>
> Is there a way in nginx to use the same functionality as the
> url_rewriter in squid? Is there a tutorial or other helpful links on
> doing caching in nginx?

http://wiki.nginx.org/NginxHttpProxyModule#proxy_cache

http {
proxy_cache_path /spool/nginx/cache levels=1:2
keys_zone=cache:10m
inactive=3h;

server {

location / {
proxy_pass ...;

proxy_cache cache;
proxy_cache_valid 200 24h;
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;

proxy_ignore_headers Expires Cache-Control;
}

As to url_rewriter, it's depend on functionality: you may use simple
"rewrite" or complex "perl_set":
http://wiki.nginx.org/NginxEmbeddedPerlModule


--
Igor Sysoev
http://sysoev.ru/en/
Subject Author Posted

nginx caching

Gabriel Ramuglia July 19, 2009 05:54AM

Re: nginx caching

Igor Sysoev July 19, 2009 06:56AM

Re: nginx caching

Gabriel Ramuglia July 19, 2009 07:21AM

Re: nginx caching

Igor Sysoev July 19, 2009 07:32AM

Re: nginx caching

john.wang507 February 19, 2011 01:36AM

Re: nginx caching

miikeh69 February 19, 2011 10:31AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 228
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready