How do I enable image caching for my jsp page ? The jsp page gets refreshed at an interval of 1 second. So I want to cache the image, so as not annoy the user ! There are 2 images, with weighing 4 KB and another 13 KB.
Asked
Active
Viewed 510 times
0
-
possible duplicate of [enable caching of images specifying a modified date](http://stackoverflow.com/questions/2155276/enable-caching-of-images-specifying-a-modified-date) – Ralph Dec 27 '12 at 11:15
1 Answers
0
The images in a html-page are like seperate Requests to the server. The caching behave is dictated by the image-download.
From now, you have two good options:
- design a javax.servlet.Filter to inject those cache-control.
- install a apache-http-server with ajp-link to the tomcat to configure the caching in .htaccess-file inside of your webapp.
I personaly prefer the apache-way because of
- caching may be realy wired and
- i like to missconfigure instead of missprogram :D
Regards

Grim
- 1,938
- 10
- 56
- 123
-
But isn't there any direct way to use, cache header. Just enable the cache header over the image source and it gets cached ! – saplingPro Dec 27 '12 at 10:23
-
Have a look at method "serveResource" in http://www.docjar.com/html/api/org/apache/catalina/servlets/DefaultServlet.java.html there is no direct way. – Grim Dec 27 '12 at 11:06