0

I am trying to cache images on my jsp page.

I know that I can cache everything like this:

httpResponse.setDateHeader("Expires", System.currentTimeMillis() + 604800000L);

But I need to set expiration cache only for images. How can I do that? What is the easiest way?

Thanks

Bob
  • 8,392
  • 12
  • 55
  • 96

1 Answers1

2

Create a servlet filter which will listen for URLs that end in *.jpg, *.gif, *.png etc. and add the expires header in the response.

Bimalesh Jha
  • 1,464
  • 9
  • 17