Disable caching of a single file with try_files directive

后端 未结 6 882
情书的邮戳
情书的邮戳 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 17:10

    You can use content-type mapping (should do the job for SPA with one .html file):

    map $sent_http_content_type $expires {
        default                    off;
        text/html                  epoch; # means no-cache
    }
    
    server {
      expires $expires;
    }
    
    
    

提交回复
热议问题