其他分享
首页 > 其他分享> > css – 重新部署webapp缩小(缓存)后的404错误

css – 重新部署webapp缩小(缓存)后的404错误

作者:互联网

我正面临着我的webapp的问题:每次我必须重新部署它(AWS)时,页面第一次都没有正确加载,因为(我相信)本地缓存有与之前部署相对应的js和css文件.我正在使用由Java备份的Angular并使用Spring Boot服务.

This is the state the page looks like

当我重新下载(例如Ctrl R)时,一切正常.为了解决这个问题,我在index.html中添加了以下元数据:

<!--Setting the content to "0" tells the browsers to always load the page from the web server.-->
  <meta http-equiv="cache-control" content="max-age=0"/>
  <meta http-equiv="cache-control" content="no-cache"/>
  <meta http-equiv="expires" content="0"/>
  <meta http-equiv="expires" content="0"/>
  <meta http-equiv="pragma" content="no-cache"/>

哪个显然不起作用.我能做什么?

解决方法:

也许你可以通过向文件添加查询来欺骗这种行为,有些想法:

<script src="myscript.js?build=mybuildversion"></script>
<link href="mystyles.css?build=mybuildversion" rel="stylesheet">

标签:css,angularjs,browser-cache,spring
来源: https://codeday.me/bug/20190623/1270091.html