Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CachingResourceResolver + GzipResourceResolver caches different results depending on what is requested first [SPR-12892] #17491

spring-issuemaster opened this issue Apr 6, 2015 · 2 comments


None yet
2 participants
Copy link

commented Apr 6, 2015

Michael de Hoog opened SPR-12892 and commented

I've configured a resource handler as below:

public void addResourceHandlers(ResourceHandlerRegistry registry)
     GzipResourceResolver gzipResolver = new GzipResourceResolver();

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


This comment has been minimized.

Copy link
Collaborator Author

commented 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!


This comment has been minimized.

Copy link
Collaborator Author

commented May 11, 2015

Brian Clozel commented

This has been backported to 4.1.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.