From f00f56551916f14ea600719417e16c942c20f18b Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Thu, 21 Nov 2019 15:33:29 +0800 Subject: [PATCH] handle http cache for static assets, except index.html and favicon.ico --- .../web/StaticResourceConfiguration.kt | 22 +++++++++++++++++++ komga/src/main/resources/application.yml | 5 +++++ 2 files changed, 27 insertions(+) create mode 100644 komga/src/main/kotlin/org/gotson/komga/infrastructure/web/StaticResourceConfiguration.kt diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/web/StaticResourceConfiguration.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/web/StaticResourceConfiguration.kt new file mode 100644 index 000000000..e580e0adc --- /dev/null +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/web/StaticResourceConfiguration.kt @@ -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()) + } +} diff --git a/komga/src/main/resources/application.yml b/komga/src/main/resources/application.yml index 4a12c0482..0fb8b1561 100644 --- a/komga/src/main/resources/application.yml +++ b/komga/src/main/resources/application.yml @@ -6,6 +6,11 @@ spring: h2: console: enabled: true + resources: + cache: + cachecontrol: + cache-public: true + max-age: 365d management: endpoints.web.exposure.include: "*"