May 13th, 2012, 06:10 AM
What effect does cacheDir have on BufferedImageHttpMessageConverter?
In my current application, I list files in a directory on a server and present the list back to the user in the browser where they may or may not see a preview of the file. Some of those files I'm able to render into BufferedImages so that they can be displayed in the browser. Files like TIFF and PDF for example I render into BufferedImage. For PDF files, I use Apache PDFBox for rendering into BufferedImage and I find it rather slow compared to TIFF files where I use ImageIO directly. I thought maybe setting the cacheDir property on BufferedImageHttpMessageConverter would cache the BufferedImages, but I'm not sure about that. When experimenting, I saw that .tmp files would get written to the cache directory, but they would't remain there. In my application, if a file has multiple pages, like TIFF and PDF files tend to have, I have user controls in my application for switching between pages, which essentially makes a request to the server to return the next/previous page as a BufferedImage. I didn't see any noticeable performance increase after setting cacheDir though if I switched back and forth to pages I already viewed. So I'm just wondering what cacheDir really does?
Should I be using something like Spring's cache abstraction and add the @Cacheable annotation to my methods that generate the BufferedImages?
Thanks in advance :-)