提交 2a537f44 编写于 作者: N nobodyiam

adjust cache control so that entry htmls are not cached, as we need them to...

adjust cache control so that entry htmls are not cached, as we need them to trigger 302 in case user is not logged in
上级 a27bb73a
......@@ -9,6 +9,7 @@ import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
......@@ -37,4 +38,21 @@ public class WebMvcConfig implements WebMvcConfigurer, WebServerFactoryCustomize
mappings.add("html", "text/html;charset=utf-8");
factory.setMimeMappings(mappings );
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// 10 days
addCacheControl(registry, "img", 864000);
addCacheControl(registry, "vendor", 864000);
// 1 day
addCacheControl(registry, "scripts", 86400);
addCacheControl(registry, "styles", 86400);
addCacheControl(registry, "views", 86400);
}
private void addCacheControl(ResourceHandlerRegistry registry, String folder, int cachePeriod) {
registry.addResourceHandler(String.format("/%s/**", folder))
.addResourceLocations(String.format("classpath:/static/%s/", folder))
.setCachePeriod(cachePeriod);
}
}
......@@ -3,13 +3,11 @@ spring:
name: apollo-portal
profiles:
active: ${apollo_profile}
resources:
cache:
cachecontrol:
max-age: 3600
server:
port: 8080
compression:
enabled: true
logging:
file: /opt/logs/100003173/apollo-portal.log
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册