https://blog.csdn.net/feiyu_may/article/details/88376945

解决方法

cd /etc/nginx

nano nginx.conf

在 location / 下方添加以下配置

  1. location ~ .*\.(html)$ {
  2. add_header Cache-Control no-store;
  3. add_header Pragma no-cache;
  4. }

解释

原文链接:https://blog.csdn.net/feiyu_may/java/article/details/88376945

  1. location ~ .*\.(html)$ { // html文件限制缓存
  2. add_header Cache-Control no-store; // 不缓存
  3. // 或者用add_header Cache-Control no-cache;替代上面那一句,协商缓存
  4. add_header Pragma no-cache;
  5. }

最终效果

  1. server {
  2. listen 80;
  3. server_name localhost;
  4. location / {
  5. root /home/dist;
  6. try_files $uri $uri/ @router;
  7. index index.html;
  8. }
  9. location ~ .*\.(html)$ {
  10. add_header Cache-Control no-store;
  11. add_header Pragma no-cache;
  12. }
  13. error_page 500 502 503 504 /50x.html;
  14. location = /50x.html {
  15. root html;
  16. }
  17. location @router {
  18. rewrite ^.*$ /index.html last;
  19. }
  20. }

修改 Nginx 配置后,重新加载

  1. sudo systemctl reload nginx