Reputation:
I have created a web application using JSF 2.0. I got feedback from my friend saying I should do "Browser Caching" as I have many images.
However I don't know how to do same in JSF. Any idea/ hint would be appreciated.
Concept on what to be done would also work.
Upvotes: 3
Views: 2993
Reputation: 1109745
Just use <h:graphicImage name="...">
instead of <img src="...">
. This way the default JSF resource handler will instruct the browser to cache them for 1 week by default, which is configureable with an implementation dependent context parameter, which is the following in case of Mojarra:
<context-param>
<param-name>com.sun.faces.defaultResourceMaxAge</param-name>
<param-value>3628800000</param-value> <!-- 6 weeks -->
</context-param>
Note, the same applies when using <h:outputScript>
and <h:outputStylesheet>
instead of <script>
and <link rel="stylesheet">
.
Upvotes: 7