1. 程式人生 > >springboot+thymeleaf解決css/js瀏覽器快取問題

springboot+thymeleaf解決css/js瀏覽器快取問題

1、springboot配置application.yaml中加入

#啟用內容版本策略 md5

spring.resources.chain.strategy.content.enabled: true

#應用於版本策略的模式的逗號分隔列表 預設/**

spring.resources.chain.strategy.content.paths: /js/web/**

2、在頁面中引入

<script th:src="@{/js/web/common.js}"></script>
<script th:src="@{/js/web/logstate.js}"></script>

3、將js檔案放入配置的paths中去