Skip to content

Consider enhancing ResourceUrlProvider to be able to change the domain, port, or scheme [SPR-12130] #16746

Closed

Description

@spring-projects-issues

Brian Clozel opened SPR-12130 and commented

Now that the new
resource handling feature is in release candidate phase, we received feedback on several aspects.

One of those feedbacks is about changing the HTTP domain that serves resources. Here are some use cases for this:

  • use of a 3rd party CDN on a separate domain (like Amazon cloudfront)
  • use of a separate, cookie-less domain for better web performance, since sending cookies with each request can be a performance issue

See this Twitter conversation (in french) for reference.

We considered allowing ResourceResolvers to return complete URLs (and not only the resource path), but the current design for the Resource (Resolver/Transformer) chain is simple and cohesive -- focused mainly on the resource path. The ability to modify the domain, port, and scheme is a separate concern.

This issue is to explore the following solution:

  • configuring globally an HTTP domain for all resolved resources though ResourceUrlProvider, making it a cross-cutting concern for ResourceResolvers
  • this configuration could be done at the java config level with WebMvcConfigurerAdapter or WebMvcConfigurationSupport

Affects: 4.1 RC2

Issue Links:

Activity

  1. spring-projects-issues commented on Aug 28, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Brian Clozel commented

    Hi Guillaume DROUET, I think this issue might interest you as well.
    Does your project need to change URL domains as part of the resolvers/transformer? Or a separate setting, as suggested here is acceptable?

    Thanks,

  2. spring-projects-issues commented on Aug 28, 2014

    @spring-projects-issues
    CollaboratorAuthor

    Guillaume DROUET commented

    Hi!

    Of course! As mentionned in your twitter conversation, serving statics from a cookie less domain is important and in my project I take care of it by allowing to set several locations to use when writing URLs. So if spring allows to do it, the users may have the choice to choose between spring and third party framework as it can be done with PathResourceResolver and VersionStrategy. Sounds good to me if we can configure everything from WebMvcConfigurerAdapter...

  3. spring-projects-issues commented on Apr 2, 2017

    @spring-projects-issues
    CollaboratorAuthor

    smallufo commented

    Hi , I recently have the same question , and find this issue.
    I noticed it is marked resolved . but I cannot find any document mentioning how to change the host of a static resource ?

    related stackoverflow : http://stackoverflow.com/q/43031682/298430

  4. spring-projects-issues commented on Apr 3, 2017

    @spring-projects-issues
    CollaboratorAuthor

    Brian Clozel commented

    It's resolved as duplicate of #16488 - and you've commented there as well.

  5. added
    type: enhancement
    status: duplicate
    in: web
    on Jan 11, 2019
  6. added this to the 4.1 GA milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webstatus: duplicatetype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions