Skip to content

Restore ETags for transformed versioned resources - #37405

Open
CCCLL wants to merge 1 commit into
spring-projects:mainfrom
CCCLL:fix/transformed-resource-etag
Open

CCCLL wants to merge 1 commit into
spring-projects:mainfrom
CCCLL:fix/transformed-resource-etag

Conversation

@CCCLL

@CCCLL CCCLL commented Oct 6, 2026

Copy link
Copy Markdown

Versioned CSS resources lose their ETag when
CssLinkResourceTransformer creates a TransformedResource. Both MVC
and WebFlux then serve the rewritten content without that response
header.

This change makes TransformedResource implement HttpResource. When
the original resource has an ETag, it derives a weak ETag from the
current transformed bytes. This also covers a CSS file whose referenced
resource URLs change while its own source version stays the same.
Other original HTTP response headers are not inherited.

For transformed resources, a configured ETag generator keeps precedence,
including when it returns null. The existing header behavior for other
HTTP resources and the conditional request flow remain unchanged.

Validation:

  • 147 focused MVC and WebFlux resource tests passed.
  • Both complete module checks passed on JDK 25:
    ./gradlew :spring-webmvc:check :spring-webflux:check, including tests,
    NullAway, Checkstyle and architecture checks.
  • The complete checks used a separate source snapshot with test server
    defaults bound to 127.0.0.1 to avoid collisions with existing local
    applications. That local fixture adjustment is outside this PR.

See #26364.

Versioned CSS resources lose their ETag when their content is
transformed to rewrite resource links.

Derive a weak ETag from the transformed bytes when the original
resource provides an ETag. Preserve configured ETag generator
precedence for transformed resources and the existing header behavior
for other HTTP resources.

See spring-projectsgh-26364

Signed-off-by: CCCLL <cccll2019@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants