676用填3 发表于 2016-8-23 09:27:32

LNMP - Nginx配置静态文件缓存时间

# cd /usr/local/nginx/conf/vhosts
# vim test.conf

server
{
    listen 80;
    server_name www.test.com;
    index index.html index.htm index.php;
    root /data/www;

    # 定义访问日志的路径和格式
    access_log /tmp/nginx_access.log test;

    # 不记录静态文件的的访问日志
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|rar|zip|gz|bz2)$ {
      access_log off;
      expires 10d;
    }

    location ~ \.(js|css) {
      access_log off;
      expires 2h;
    }
}


页: [1]
查看完整版本: LNMP - Nginx配置静态文件缓存时间