caching images served by servlet

后端 未结 4 1366
臣服心动
臣服心动 2020-12-03 01:44

I\'m serving up images from my servlet. The response content type is image/jpeg. I find that images requested from my servlet are not cached. How do I get them to be cached

4条回答
  •  囚心锁ツ
    2020-12-03 02:32

    Ok.. looks like the default header fields should enable caching. I found a solution in another forum. Apparently, you need to explicitly set a content-length in the response. Wonder why though. I thought the HttpServletResponse would do that for us. Anyway, it worked like a charm and the image is getting cached nicely.

提交回复
热议问题