Description
Michael de Hoog opened SPR-12892 and commented
I've configured a resource handler as below:
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
GzipResourceResolver gzipResolver = new GzipResourceResolver();
registry.addResourceHandler("/assets/**")
.addResourceLocations("classpath:public/assets/")
.setCachePeriod(0)
.resourceChain(true)
.addResolver(gzipResolver);
}
When requesting a resource from the server using curl, adding the "Accept-Encoding: gzip" header (using curl's --compressed flag), the GzipResourceResolver finds a .gz resource and returns it:
curl --compressed -v http://localhost:8080/assets/client.js
If I then request the same resource without the "Accept-Encoding: gzip" header, the gzipped version is still returned, as it is cached by the CachingResourceResolver:
curl -v http://localhost:8080/assets/client.js
If I restart the server and first call curl without the "Accept-Encoding: gzip" header, the non gzipped version is returned.
Then requesting the resource with the header still returns the non gzipped version.
To summarise, the server returns different results for the same request, depending on the request headers in the first request for the resource. This is because the CachingResourceResolver caches the resource only using the requestPath as the key, ignoring request headers.
Is this expected behaviour?
Affects: 4.1.6
Activity
spring-projects-issues commentedon May 4, 2015
Brian Clozel commented
This has been resolved in master - will backport this for 4.1.7 (in the 4.1.x branch) soon.
Thanks for reporting this!
spring-projects-issues commentedon May 11, 2015
Brian Clozel commented
This has been backported to 4.1.x.