Why Spring message converters still being invoked in @Cachable methods

lets say I have two methods in my controller to support both json and xml.

@RequestMapping(value = "/get/response.json", method = RequestMethod.GET)
public @ResponseBody JSONResponse getJsonResponse(){
    return responseService.getJsonResponse();
@RequestMapping(value = "/get/response.xml", method = RequestMethod.GET)
public  @ResponseBody XMLResponse getXmlResponse(){
    return responseService.getXmlResponse();

And two message converters, marshalling my objects into suitable response.

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
            <ref bean="jsonConverter"/>
            <ref bean="xmlConverter" />

The problem is that Spring 3.1, even though method is annotated with @Cachable, still invokes marshaller for every call. It caches state of the object before marshalling. This is not acceptable because performance is crucial here and marshalling is too expensive for me. I expected Spring to cache the final response in such case. Am I doing something wrong here?


To avoid this issue ehcache web caching can be used: http://www.ehcache.org/documentation/user-guide/web-caching

It works by simply adding filter to web.xml and provides caching of HTTP responses.



Need Your Help

Performance of canvas in xcode simulator with retina display

xcode ipad html5 canvas ios-simulator

I have an html5 canvas game, limited to 30FPS. This runs fine (@30FPS) on the iPad2 and the xcode simulator when set to iPad2.

Check if file exist Linux bash

linux bash file

So I'm trying to check if a file exists or not and then the script is supposed to do something if it does. The problem I'm having is actually getting it to recognize that something is actually ther...