我使用位置部分以这种方式使用nginx为Angular 2应用程序提供服务:
location / {
try_files $uri $uri/ /index.html =404;
}
try_files指令尝试在根目录中查找请求的uri,如果找不到它,则只返回index.html
如何禁用index.html文件的缓存?
最佳答案
使用nginx命名位置找到解决方案:
location / {
gzip_static on;
try_files $uri @index;
}
location @index {
add_header Cache-Control no-cache;
expires 0;
try_files /index.html =404;
}