从此question它显示弹簧安全管理缓存用于弹簧启动。从春天启动documentation它展示了如何使用设置资源高速缓存:如何选择性地禁用弹簧启动缓存(manifest.appcache)
spring.resources.cache-period= # cache timeouts in headers sent to browser
的cache-period
是伟大的春季启动所有预定义的静态位置(即/css**
,/js/**
,/images/**
),但我也产生manifest.appcache
我的静态资产的离线下载,并且由于所有上述弹簧安全的/ boot发回缓存头与manifest.appcache
"method": "GET",
"path": "/manifest.appcache",
"response": {
"X-Application-Context": "application:local,flyway,oracle,kerberos:8080",
"Expires": "Tue, 06 Oct 2015 16:59:39 GMT",
"Cache-Control": "max-age=31556926, must-revalidate",
"status": "304"
}
我想知道如何添加排除了manifest.appcache
。 IE和Chrome似乎'app正确的事情'与appcache无关我的标题,但FF似乎是一个更特别的一点在注意什么时候appcache已经改变,我认为我的缓存头正在搞砸了。
编辑: 我应该从源头上增加对WebMvcAutoConfiguration它显示的缓存是如何设置的资源,我只是不知道该如何选择了我1时禁用W/O可能破坏什么春天启动的其余部分在这个文件中设置。
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (!this.resourceProperties.isAddMappings()) {
logger.debug("Default resource handling disabled");
return;
}
Integer cachePeriod = this.resourceProperties.getCachePeriod();
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/")
.setCachePeriod(cachePeriod);
}
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**")
.addResourceLocations(RESOURCE_LOCATIONS)
.setCachePeriod(cachePeriod);
}
}
只需添加扩展'WebMvcConfigurerAdapter'一个类,并添加了该资源应该做的伎俩一个特定的规则。 – 2014-10-06 18:23:59
我试过这个: '''@Override public void addResourceHandlers(ResourceHandlerRegistry registry) { super.addResourceHandlers(registry); registry.addResourceHandler(“/ manifest.appcache”)。addResourceLocations(“/”)。setCachePeriod(0); }''' 但我得到了404。 – JimB 2014-10-08 11:13:39
使用'/'将使它尝试从Web应用程序的根目录检索。确保/覆盖文件的正确物理位置。 – 2014-10-08 17:52:02