Skip to content

WebContentGenerator not backwards compatible [SPR-13207] #17799

Closed
@spring-projects-issues

Description

@spring-projects-issues

Mike Noordermeer opened SPR-13207 and commented

After the rework of the caching in WebContentGenerator (see #16413), it is no longer backwards compatible with some older configurations. In our case, we have the following XML config:

    <mvc:interceptors>
        <!-- WebContentInterceptor, taking care of caching headers on static resources
             and anti caching headers on other resources -->
        <bean class="org.springframework.web.servlet.mvc.WebContentInterceptor">
            <!-- By default, do not cache anything -->
            <property name="cacheSeconds" value="0" />
            <property name="alwaysMustRevalidate" value="true" />
            <property name="cacheMappings">
                <props>
                    <!-- Cache for one year -->
                    <prop key="/**/*.cache.*">31536000</prop>
                </props>
            </property>
        </bean>
</mvc:interceptors>

This causes all resources to have 'no-cache' headers applied. Reason for this is that the (deprecated) alwaysMustRevalidate triggers the variable usePreviousHttpCachingBehavior. This causes checkAndPrepare(HttpServletRequest, HttpServletResponse, CacheControl) to completely ignore the CacheControl setting specific to the request.

Workaround is to make sure you do not combine any of the deprecated methods with custom cacheMappings, but it is probably better to get this fixed to prevent surprises on upgrades.


Affects: 4.2 RC2

Issue Links:

Referenced from: commits ef0eb01

1 votes, 3 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions