mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-19 01:58:16 +08:00
Configure a cache busting resource chain
This commit configures a resource chain with `resources.chain.strategy.content.enabled`, enabling cache busting for static resources based on the hash of their content. A template helper (here a Groovy Closure) is added to the model given to the view for appending hashes to static links such as: "/css/spring.css" -> "/css/spring-d35c4193cd32e7e44cda5737205c0c0e.css" Fixes #321
This commit is contained in:
@@ -29,6 +29,7 @@ import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.scheduling.annotation.AsyncConfigurerSupport
|
||||
import org.springframework.scheduling.annotation.EnableAsync
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
|
||||
import org.springframework.web.servlet.resource.ResourceUrlProvider
|
||||
|
||||
/**
|
||||
* Initializr service application. Enables legacy STS support for older
|
||||
@@ -47,8 +48,9 @@ class InitializrService {
|
||||
@Bean
|
||||
@SuppressWarnings("deprecation")
|
||||
LegacyStsController legacyStsController(InitializrMetadataProvider metadataProvider,
|
||||
ResourceUrlProvider resourceUrlProvider,
|
||||
GroovyTemplate groovyTemplate) {
|
||||
new LegacyStsController(metadataProvider, groovyTemplate)
|
||||
new LegacyStsController(metadataProvider, resourceUrlProvider, groovyTemplate)
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
@@ -13,6 +13,11 @@ spring:
|
||||
jackson:
|
||||
serialization:
|
||||
write-dates-as-timestamps: false
|
||||
resources:
|
||||
chain:
|
||||
strategy:
|
||||
content:
|
||||
enabled: true
|
||||
|
||||
initializr:
|
||||
env:
|
||||
|
Reference in New Issue
Block a user