From this question it shows that spring security manages cache for spring boot. From the spring boot documentation it shows how to set cache for resources using:
spring.resources.cache-period= # cache timeouts in headers sent to browser
The cache-period
is great for all the predefined static locations for spring boot (i.e. /css**
, /js/**
, /images/**
) but I'm also generating a manifest.appcache
for offline downloading of my static assets and due to all the above spring security/boot sends back cache headers with the 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"
}
I'd like to know how to add an exclusion for manifest.appcache
. IE and Chrome seem to 'do the right thing' with appcache regardless of my headers, but FF seems to be a little more peculiar in noting when the appcache has changed and I'm thinking my cache headers are screwing it up.
EDIT: I should add from the source for WebMvcAutoConfiguration it shows how the cache is setup for the resources, I'm just unsure how to selectively disable for my 1 case w/o potentially disrupting the rest of what spring boot sets up in this file.
@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
and adding a specific rule for that resource should do the trick. – Enforce@Override public void addResourceHandlers(ResourceHandlerRegistry registry) { super.addResourceHandlers(registry); registry.addResourceHandler("/manifest.appcache").addResourceLocations("/").setCachePeriod(0); }
but i get a 404. – Berton/
will make it try to retrieve from the root of the web application. Make sure that the / covers the correct physical location of the file. – Enforce/public
, which is the same location index.html lives. – Berton/public
not/
. – Enforce