Bob
Bob

Reputation: 8724

Add expire cache for images in JSP

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

Upvotes: 0

Views: 496

Answers (1)

Bimalesh Jha
Bimalesh Jha

Reputation: 1504

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

Upvotes: 2

Related Questions