Skip to content

Add ResourceHttpRequestHandler for efficiently serving static resouces [SPR-7116] #11776

Closed
@spring-projects-issues

Description

@spring-projects-issues

Keith Donald opened SPR-7116 and commented

The Spring JavaScript module of the Web Flow project contains a ResourceServlet that efficently serves static resources such as .css and .js files. This servlet has proven generally useful and, as a user, I'd like this functionality available in Spring Framework's core web support. Specifically:

  • I'd like this functionality to be configurable within a Spring MVC DispatcherServlet, without requiring another servlet to be configured in web.xml. This simplifies setup and also allows for greater configuration control with the Spring MVC namespace.

  • Caching should be aggressive. All resources served up should be cached with a far out expiration date (e.g. 1 year).

  • Compression should be applied to text-based resources e.g. .css, .js, .json, and .xml files (should be possible to disable)

  • Minification should be applied to text-based resources where possible e.g. .js (should be possible to disable)

  • Resource bundling should be supported. This provides the ability to load multiple resources in one HTTP request, which can improve performance.

  • Resource versioning should be supported. This causes clients to refresh cached resources when a new version of the application is deployed. This prevents clients from working with stale content after deployment of a new version. (should be possible to disable, when disabled no caching should be performed)

  • It should be possible to serve resources out of the webapp root as well as jar file bundles.

  • The ResourceHandler should aim to be compatible with JSF 2.0 resource handling as far as possible (we should not make compromises but we shouldn't be different when we can align).

The ResourceHandler should also be capable of being the "default handler" for the DispatcherServlet. This would provide a static resource handling fallback similar to how the Servlet Container works.


Affects: 3.0.2

Attachments:

Sub-tasks:

Issue Links:

9 votes, 16 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions