如何为CSS,JS,JSP文件提供版本控制 [英] how to provide versioning for css, js, jsp files

查看:89
本文介绍了如何为CSS,JS,JSP文件提供版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个具有多个视图的单页Web应用程序.为了渲染这些视图,使用了ng-if.这些视图没有标题或正文部分,而只有html代码.

I have developed a single page web application with multiple views on it. For rendering these views ng-if has been used.These views don't have a header or a body section but only the html code.

每个视图都有一个单独的控制器.许多单击功能已使用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.

问题是,无论何时我对视图(.jsp文件)或js或css文件进行任何更改,在部署新的WAR文件而不清除缓存并进行硬刷新(ctrl + F5)后,它都不会反映出来. /R).

The problem is whenever I make any changes to the views(.jsp file) or the js or the css file it won't get reflected after deploying the new WAR file without clearing cache and doing a hard refresh(ctrl+F5/R).

我以服务人员的形式得到了答复,但是IE10不支持它.

I got an answer in form of service worker but it's not supported by IE10.

我需要一个永久的解决方案,因为我有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.

我唯一想做的是,只要.css,.jsp,.js文件中有更新,浏览器就应该用较新的文件替换较旧的文件.

The only think I wanted is whenever there is an update in .css,.jsp,.js files the browser should replace the older with the newer one.

预先感谢

推荐答案

您可以做的就是对HTML页面中包含的所有文件进行版本控制

What you can do is version all the files included in your HTML pages like so

<html>
<head>
  <script src='whatever.v1_2_3.js'></script>
  <link href='whatever.v3_4_5.css'/>
</head>
<body>
...
</body>
</html>

这样,每当您更改HTML中的版本时,如果文件尚未在缓存中,则会下载文件,从而迫使浏览器始终保持最新状态.

That way, whenever you bump the versions in your HTML, the files will get downloaded if not already in cache forcing the browser to be always up-to-date.

这篇关于如何为CSS,JS,JSP文件提供版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆