HCL Commerce Version 9.1.20.0

HCL Commerce version 9.1.20.0 wc-server.xml update

In HCL CommerceVersion 9.1.20.0 runtime, a new HttpResponseHeaderConfiguration block is added to the wc-server.xml file to support Cache-Control and Pragma HTTP header configuration for REST responses.

This configuration block is disabled by default. To use this functionality, you must explicitly set enable="true" in the configuration.

For more information about the wc-server.xml configuration see HCL Commerce configuration file (wc-server.xml)

For more details about configuring REST response caching headers, see Caching strategies for REST services.

Configuration update
You can configure the HttpResponseHeaderConfiguration component in wc-server.xml to manage REST response headers. Use the following XML snippet to update your configuration.
<component
    compClassName="com.ibm.commerce.foundation.rest.util.HttpResponseHeaderConfigurationHelper"
    enable="true"
    name="HttpResponseHeaderConfiguration">
    
    <property>
        <RestTemplateToHttpHeaderMapping>
            <SetHeaderIfEmpty name="Cache-Control" value="no-store, no-cache, s-maxage=0, max-age=0, must-revalidate"/>
            <SetHeaderIfEmpty name="Pragma" value="no-cache"/>
        </RestTemplateToHttpHeaderMapping>

        <RestTemplateToHttpHeaderMapping
            httpMethods="GET"
            responseCodes="200"
            restTemplates="store/{storeId}/contract">
            <SetCacheControlDirective name="private"/>
            <SetCacheControlDirective name="max-age" value="600"/>
        </RestTemplateToHttpHeaderMapping>

        <RestTemplateToHttpHeaderMapping
            httpMethods="GET"
            responseCodes="200"
            restTemplates="
                store/{storeId}/adminLookup
                store/{storeId}/associated_promotion
                store/{storeId}/configuration
                store/{storeId}/country/country_state_list
                store/{storeId}/currency_format
                store/{storeId}/espot/{name}
                store/{storeId}/espot/{name}/type/{type}
                store/{storeId}/features
                store/{storeId}/marketplace-sellers
                store/{storeId}/online_store
                store/{storeId}/page
                store/{storeId}/page_design
                store/{storeId}/seo/token
                store/{storeId}/seo/urlkeyword
                store/{storeId}/seo/urls
            ">
            <SetCacheControlDirective name="max-age" value="0"/>
            <SetCacheControlDirective name="s-maxage" value="600"/>
        </RestTemplateToHttpHeaderMapping>
    </property>
</component>