Commit d80537a3 authored by Jason Song's avatar Jason Song Committed by GitHub

Merge pull request #1535 from nobodyiam/adjust-cache-control

adjust cache control so that entry htmls are not cached, as we need them to trigger 302 in case user is not logged in
parents a27bb73a 2a537f44
......@@ -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% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment