[Original] Uncle Experience Sharing (74) nginx accelerate static files

Configuration by location

    location ~ \.html$ {
        add_header 'Cache-Control' 'no-cache';
    }
    location ~ \.(js|css|gif|jpg|jpeg|png|bmp|swf)$) {
        access_log off;
        expires 7d;
    }

Arranged in the location

    location ^~ /testpath {
        if ($uri ~ \.html$) {
                add_header 'Cache-Control' 'no-cache';
        }
        if ($uri ~ \.(js|css|gif|jpg|jpeg|png|bmp|swf)$) {
                access_log off;
                expires 7d;
        }
        ...
    }

 

Guess you like

Origin www.cnblogs.com/barneywill/p/11126849.html