handle http cache for static assets, except index.html and favicon.ico

This commit is contained in:
Gauthier Roebroeck 2019-11-21 15:33:29 +08:00
parent aa969fd8bd
commit f00f565519
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,22 @@
package org.gotson.komga.infrastructure.web
import org.springframework.context.annotation.Configuration
import org.springframework.http.CacheControl
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration
class StaticResourceConfiguration : WebMvcConfigurer {
override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
registry//.setOrder(Ordered.HIGHEST_PRECEDENCE)
.addResourceHandler(
"/index.html",
"/favicon.ico"
)
.addResourceLocations(
"classpath:public/index.html",
"classpath:public/favicon.ico"
)
.setCacheControl(CacheControl.noStore())
}
}

View file

@ -6,6 +6,11 @@ spring:
h2:
console:
enabled: true
resources:
cache:
cachecontrol:
cache-public: true
max-age: 365d
management:
endpoints.web.exposure.include: "*"