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
  • 7,802
  • 12
  • 47
  • 84

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,432
  • 9
  • 14