简体   繁体   中英

JS caching issue with JSP

I've been getting duplicated values in my database from what I believe is from my call to my JS file. I need some verification, that the way I'm generating a new JS version number is right.

Integer verCount = 0;


<script src="include/test.js?version=<%=verCount++ %>"></script>

Thanks.

Try this:

<script src="include/test.js?version=<%= (new Date()).getTime() %>"></script>

A timestamp should be unique each time don't worry about keeping a count. This will cause the js file to be reloaded each time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM