Reputation: 3599
With thymeleaf and following code
<script th:src="@{/js/init.js}"></script>
I would like to make it like following in order to avoid browser caching for this file
<script th:src="@{/js/init.js?${minute}}"></script>
${minute} will be current time minute.
Upvotes: 0
Views: 2313
Reputation: 2511
If you just want to provide versioned static files, you might try spring resource versioning. One possible solution using configuration only is described here https://stackoverflow.com/a/49040930.
Upvotes: 0
Reputation: 3599
I solve the question by use the following, it's a bit longer than expected.
<script th:src="@{/js/init.js(minute=${#dates.format(#dates.createNow(), 'mm')})}"></script>
Upvotes: 0
Reputation: 16604
Try:
<script th:src="@{/js/init.js(minute=${minute})}"></script>
Reference: Standard URL Syntax
Upvotes: 2