【原创】大叔经验分享(74)nginx对静态文件加速

通过location配置

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

在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;
        }
        ...
    }
原文地址:https://www.cnblogs.com/barneywill/p/11126849.html