我有一个JSF组件,它通过一个按钮通过ajax请求刷新。该组件具有按值变化的图像。如果我查看网络请求,我可以看到我的浏览器没有缓存图像,但每次点击都会请求它们。这导致了某种类型的弹出"在视图渲染中。
我希望通过缓存图像来加快刷新时间和渲染时间。我尝试在GET方法上使用RequestFilter,它将Cache-Control标头设置为" public"但是没有用。
有什么想法吗?
<!-- IMPLEMENTATION -->
<composite:implementation>
<h:panelGrid columns="2">
<c:choose>
<c:when test="#{cc.attrs.latencia ge cc.attrs.umbralAlto}">
<p:graphicImage value="#{resource['images:rojo.png']}"/>
</c:when>
<c:when test="#{(cc.attrs.latencia lt cc.attrs.umbralAlto) and (cc.attrs.latencia ge cc.attrs.umbralMedio)}">
<p:graphicImage value="#{resource['images:ambar.png']}"/>
</c:when>
<c:otherwise>
<p:graphicImage value="#{resource['images:verde.png']}"/>
</c:otherwise>
</c:choose>
<h:outputText value="#{cc.attrs.latencia} ms."/>
</h:panelGrid>
</composite:implementation>
<h:body>
<h:form id="miForm">
<h:commandButton id="boton" value="Generar Latencia">
<f:ajax render="@form" event="click" listener="#{latencyBean.actualizarLatencia()}"/>
</h:commandButton>
<miscomponentes:LatencyIndicator latencia="#{latencyBean.latencia}"/>
</h:form>
</h:body>
答案 0 :(得分:4)
这可能有多种原因:
Development
中的上下文参数javax.faces.PROJECT_STAGE
将项目阶段设置为web.xml
?因为在这种情况下JSF禁用缓存。将参数设置为Production
(默认值)应启用缓存。