Welcome! Log In Create A New Profile

Advanced

Caching needed, but makes kitty sad.

June 12, 2009 10:04PM
Hai peeps! =^_^=

I have a system that stores a lot of images in a database. What I'm
running is an avatar site, and there are times when it seems everyone
has decided to update their avatars all at the same time. With nearly
70% of our non-static image requests being little 32x32 icons for all
the items that can be equipped, mass amounts of icon loads sometimes
makes the site run about a second or two slower than usual.

I came to the obvious conclusion the best way to resolve this is to have
nginx cache these little item icons. Unfortunately, I have tried and
failed to make this happen. I think having nginx caching them would
greatly improve performance since it would not have to access the
back-end FastCGI servers to get the icons, they'd be local (which is
always faster, so yay). Below is the server block in question, I
apologize in advance if the regex for /avatars/ causes any negative side
effects.

server {
listen 80;
server_name varusonline.com;
root /usr/local/www/varusonline.com/;

location / {
gzip on;
gzip_types image/png image/gif image/jpeg
text/plain text/javascript text/css;
}

location /avatars/ {
rewrite
^/avatars/([-0-9]+)(|_head|_full)\.(png|gif|jpg)(\?(.*))?$
/avatar.php?u=$1&show=$2&format=$3&$5 last;
}

location /domains/ {
rewrite
^/domains/([a-z]+)/([-0-9a-z.,]+)/([-0-9a-z.]+)?(\?(.*))?$
/domains.php?$1=$2&item=$3&$5 last;
}

location /img_view/ {
set $img $document_uri;
rewrite ^/img_view/(avi|bod)-([0-9]+).png$
/img_view.php?subset=$1&img_id=$2 last;
set $droot /usr/local/www/caches/img_view/;

proxy_store $droot${img};

if (!-f $droot${img}) {
fastcgi_pass fcgi;
}

if (-f $droot${img}) {
expires max;
}
}

location ~ \.php$ {
fastcgi_pass fcgi;
}
}

Through all of this with everything I have tried, the cache folder is
still empty, which makes this little kitty sad. Is there a way to make
nginx cache images from just that one script?

Tanks, Jessica. =^_^=

-------------------
Owner, Varus Online
http://varusonline.com/
Member Support: 530 383 3059

--- Useful Links ---
Frequently Asked Questions: http://varusonline.com/forum/viewtopic.php?t=461
Newbie Guide: http://varusonline.com/forum/viewtopic.php?t=7430
Useful Tips: http://varusonline.com/forum/viewtopic.php?t=6803

When taking over the world, use zombie squirrels.
Nobody will ever see it coming. >.>
Subject Author Posted

Caching needed, but makes kitty sad.

Lady Serena June 12, 2009 10:04PM

Re: Caching needed, but makes kitty sad.

anomalizer June 20, 2009 12:47PM

Re: Caching needed, but makes kitty sad.

Lady Serena June 20, 2009 01:20PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 221
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