**To set it on the HTML/JSF responses you can configure it in your layouts directly with the expression language:**
Directly in the layout:
<f:event type="preRenderView" listener="#{facesContext.externalContext.response.setHeader('Cache-Control', 'no-cache, no-store')}" />
In a Managed Bean, called in the layout:
<f:event type="preRenderView" listener="#{responseHeader.setNoCache}" />
@javax.faces.bean.ManagedBean
@ApplicationScoped
public class ResponseHeader {
public void setNoCache() {
HttpServletResponse response = (HttpServletResponse) FacesContext
.getCurrentInstance().getExternalContext().getResponse();
response.setHeader("Cache-Control", "no-cache, no-store");
}
}
----------
**Response Header Filter**
To generally manage response headers also for other resources than the HTML/JSF responses (e.g. images etc.) the best way is to [create a own Servlet Filter][1] servlet filter][1] or use the exisitng one like [ResponseHeaderFilter][2][ResponseHeaderFilter][2].
----------
**Onyl expires header**header for all resources**
If you only want to conrol control the expires header, there is already a nice built in servlet filter for that.
[See tomcat documentation for more info][3]
----------
**With Apache**
If you use the [Apache Integration][4] you can use the [Module mod headers][5] or the [Module mod expires][6]
expires][6].
[1]: http://livingtao.blogspot.ch/2012/01/servlet-filter-to-set-response-headers.html
[2]: http://code.google.com/p/responseheaderfilter/
[3]: https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/filters/ExpiresFilter.html
[4]: http://www.xpertivy.ch/releases/Xpert.ivy/latest/documents/ServerGuideHtml/ivy.server.integration.apacheserver.html
[5]: http://httpd.apache.org/docs/current/mod/mod_headers.html
[6]: http://httpd.apache.org/docs/current/mod/mod_expires.html