在 js 文件或视图文件或 css 文件中所做的更改不会反映给用户 [英] Changes made in js file or views file or css file doesn't gets reflected for the user
问题描述
我开发了一个具有多个视图的单页 Web 应用程序.为了渲染这些视图,ng-if
已被使用.
I have developed a single page web application with multiple views on it. For rendering these views ng-if
has been used.
每个视图都有一个单独的控制器.许多单击功能已使用 Jquery 处理.对于后端,已经使用了java.整个应用在spring MVC
中开发,部署在WebLogic
上.
Each view has a separate controller. Many click functionality has been handled using Jquery. For backend, java has been used. The whole application has been developed in spring MVC
and deployed on WebLogic
.
问题是每当我对视图或 js 文件进行任何更改时,它都不会在部署新 WAR 文件后不清除缓存和硬刷新后得到反映(ctrl+F5/R)
.
The problem is whenever I make any changes to the views or the js file it won't get reflected after deploying the new WAR file without clearing cache and doing a hard refresh(ctrl+F5/R)
.
几分钟前我得到了这个问题的答案,它与 ServiceWorker 和 appCache 相关,但它不再出现在答案列表中.有没有人对此有任何想法?
I got an answer to this question few minutes ago which was related to ServiceWorker and appCache but it no more in the answer list. Do anyone have any idea about this?
我需要一个永久的解决方案,因为我有超过 5000
个用户,我不能要求每个人在每次部署后都这样做.
I need a permanent solution for this as I have more than 5000
users and I can't ask everyone to do this after each deployment.
当我将版本包含在 index.jsp
中时,例如 (filename.js?version=2.1)
,我已经尝试提供它.但这似乎对我不起作用.我没有在 chrome
或任何其他浏览器上测试过这个,因为只有 IE10
、edge
对我和用户可用.>
I have tried to provide a version when I include it in an index.jsp
like (filename.js?version=2.1)
. But this doesn't seem working for me. I haven't tested this on chrome
or any other browser as only IE10
, edge
is available for me as well as the users.
推荐答案
在导入的 JS 文件末尾添加查询仅适用于客户端语言.
如果您使用的是 JSP 文件,您可以在文件的开头添加它,它将禁用缓存
Adding a query at the end of JS file imported only work on a client side language.
If you are using a JSP file you can add this at the beginning of your file it will disable caching
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader("Expires", -1);
%>
对于 IE,您需要添加这些 HTML 标签:
For IE you need to add these HTML tags :
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
您可以在 response.setDateHeader("Expires", -1); 中指定文件的到期日期;
请参阅此了解更多信息
You can specify an expiration date for the file in response.setDateHeader("Expires", -1);
See this for more information
这篇关于在 js 文件或视图文件或 css 文件中所做的更改不会反映给用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!