Repository navigation
Description
Rossen Stoyanchev opened SPR-10933 and commented
Currently ResourceHttpRequestHandler uses a simple algorithm that takes the request path and tries to find a matching resource under one or more pre-configured locations, either under the web application root or on the classpath (e.g. under /META-INF/public-web-resources"). In order to implement more sophisticated resource serving, it should be possible to configure additional strategies for resolving the request path to a Resource, possibly even transforming the resource along the way.
A common use case is fingreprinting URLs to allow aggressive cache headers while still detecting changes when they occur (#14944). For this scenario to work a request path of "foo-e36d2e05253c6c7085a91522ce43a0b4.css" should resolve to resource "foo.css". The reverse should also be possible, i.e. a view should be able to look up the actual URL to use for "foo.css", e.g. "foo-e36d2e05253c6c7085a91522ce43a0b4.css".
Additional use cases include detecting gzipped files (extension ".gz") and serving them instead if the client accepts "gzip" content encoding, locating "css.less" files where ".css" is requested, etc.
In addition to locating resources, it should also be possible to transform resources. For example less-to-css transformation, gzipping, js/css minifying, etc.
Affects: 3.2.4
Issue Links:
- Support Content-based Hash Fingerprinted URLs in ResourceHttpRequestHandler [SPR-10310] #14944 Support Content-based Hash Fingerprinted URLs in ResourceHttpRequestHandler ("is depended on by")
- Add support for configuring ResourceResolver's through the MVC config [SPR-10951] #15579 Add support for configuring ResourceResolver's through the MVC config ("is depended on by")
- use RestUrlRewriteFilter to rewrite url from "/foo.gif" to "/static/foo.gif" for visit static resource [SPR-6134] #10802 use RestUrlRewriteFilter to rewrite url from "/foo.gif" to "/static/foo.gif" for visit static resource ("is duplicated by")
- Improve handling of static resources [SPR-7400] #12058 Improve handling of static resources ("is duplicated by")
3 votes, 10 watchers
Activity
spring-projects-issues commentedon Jun 26, 2014
Christopher Smith commented
This issue is marked as "complete", but the current 4.1.0.BUILD reference doc doesn't appear to discuss the new capabilities. Did I overlook it, or is it yet to be added?
spring-projects-issues commentedon Jun 26, 2014
Brian Clozel commented
Hi Christopher Smith - you're right, documentation is not there yet.
We're using a sample project to test things out; do you have a special use case in mind or you'd just like to know how this works?
Feedback is welcomed!
Note that we're still validating all use cases and that the API should be fixed during the RC phase.
spring-projects-issues commentedon Jun 26, 2014
Rossen Stoyanchev commented
Indeed there is no text summarizing the approach yet. The sample Brian referenced will be the basis for our SpringOne presentation so it is shows the end result albeit without the discussion. You can also have a look around the source code in the package where ResourceHttpRequestHandler is. You'll see the new abstractions there, their Javadoc should help too.
spring-projects-issues commentedon Jul 24, 2014
Brian Clozel commented
Hi Christopher Smith, here's a blog post with more details on this.