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

Consider reducing the number of static resource locations that are configured by default #28295

Open
wilkinsona opened this issue Oct 12, 2021 · 3 comments
Labels
type: task A general task
Milestone

Comments

@wilkinsona
Copy link
Member

See spring-projects/spring-framework#27538 for some background. We have four default locations at the moment:

  • /static
  • /public
  • /resources
  • /META-INF/resources

Lots of apps will only use one of these and some will even use none of them, yet they'll be paying a cost for all four. I think we should consider reducing the number of default locations, or perhaps we can be smarter about how they're configured and avoid passing non-existent locations into MVC and WebFlux.

Reducing the default locations would arguably also make things easier for users as it'll ensure more consistency across apps that are using the defaults.

/cc @rstoyanchev

@wilkinsona wilkinsona added the type: task A general task label Oct 12, 2021
@wilkinsona wilkinsona added this to the 3.0.x milestone Oct 12, 2021
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Oct 13, 2021

The list is now trimmed in both ResourceHttpRequestHandler and ResourceWebHandler, so therefore it shouldn't be necessary to trim it before it's passed, at least not for efficiency.

Note that when the list is trimmed, ServletContext "/" does remain as a location because technically it exists, but it doesn't mean it contains any static resources. I can't think of a good way to tell if it does contain static resources or not at the Spring Framework level, but if there is any further knowledge at the Boot level, that's something that could be filtered out from the list of locations.

@scottfrederick scottfrederick added the status: blocked An issue that's blocked on an external project change label Nov 1, 2021
@scottfrederick scottfrederick removed the status: blocked An issue that's blocked on an external project change label May 4, 2022
@philwebb
Copy link
Member

philwebb commented Oct 5, 2022

Lets push this back so that the 3.0 upgrade isn't harder than it needs to be.

@philwebb philwebb modified the milestones: 3.0.x, 3.x Oct 5, 2022
@sdeleuze
Copy link
Contributor

sdeleuze commented Oct 16, 2022

While working on spring-projects/spring-framework#27619 and spring-projects/spring-framework#29322, I noticed that the /META-INF/resources default configuration has the interesting side effect to make WebJars versioned URLs working out of the box without webjars-locator-core dependency and without any user configuration, which is great given the pretty huge efficiency impact of webjars-locator-core at startup, see this comment for details.

Notice webjars/webjars-locator-core/issues/96 will hopefully allow Spring Framework to support WebJars efficiently in a not too far future (both versioned and version-les URLs) without having to rely on /META-INF/resources default configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

5 participants