vue部署在nginx禁止html文件缓存


主要是匹配到 location ~.*\.(html)$就添加请求头,禁止缓存:
add_header 'Cache-Control' 'private,no-store,no-cache,must-revalidate,proxy-revalidate';

server {
    listen       80;
    server_name  www.example.com;
    set $package 'com.example.www';
    
    index index.html index.htm index.php;
    root  /datas/website/$package/public;
    
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }   

    location ~.*\.(html)$
    {
        add_header 'Cache-Control' 'private,no-store,no-cache,must-revalidate,proxy-revalidate';
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
        expires      7d;
    }
    location ~ .*\.(js|css)?$ {
        expires      12h;
    }

    location /api/{
          proxy_pass  http://api.d.dewujx.com/;
    }

    location ~ .*.(svn|git|cvs){deny all;}

    access_log  /datas/logs/nginx/$package.log;
}

版权声明,转载请附上原文链接及本声明: https://blog.yongit.com/note/894281.html