Nginx Configuration

linkaiyi
Follow

configure special rules for static files

The reason is that you have two blocks that match to image files:

location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {

This means that nginx only uses the latter one for your image files.

You need to change the location statements like this:

location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
    try_files $uri =404;
}

location ~ \.(?:swf|pdf|mov|fla|zip|rar)$ {
    try_files $uri =404;
}

Now the image files match only the first block, so it is used.

Object has 0 attachments

Was this article helpful?

This article is viewed 56 times!

Recent Viewed Articles

0 Comments

Leave a Comment

Support