Disable caching of a single file with try_files directive

后端 未结 6 764
情书的邮戳
情书的邮戳 2021-02-01 16:42

I\'m serving Angular 2 application with nginx using location section this way:

location / {
  try_files $uri $uri/ /index.html =404;
}

try_file

6条回答
  •  时光说笑
    2021-02-01 16:55

    Found a solution using nginx named locations:

    location / {
        gzip_static on;
        try_files $uri @index;
    }
    
    location @index {
        add_header Cache-Control no-cache;
        expires 0;
        try_files /index.html =404;
    }
    

提交回复
热议问题