Peter Penzov
Peter Penzov

Reputation: 1668

Cache image in browser

I have a JSF page with very big images - 3.4 Mb. I use this code to call the image

<div data-src="resources/images/slide1.png">

Is there any way to cache the image into client browser because every time it takes 3-4 seconds to download the picture?

Upvotes: 2

Views: 1121

Answers (1)

BalusC
BalusC

Reputation: 1108642

Reference it as JSF resource. Then JSF resource handler will automatically take care of caching. Its default expiration time is configurable in web.xml.

So instead of

<div data-src="resources/images/slide1.png">

do

<div data-src="#{resource['images/slide1.png']}">

See also:

Upvotes: 4

Related Questions