我们正在使用 JSF 2.0 / Richfaces 4.2.2 创建一个应用程序。该页面在 IE9(3-4 秒)中加载速度很快,但在 Chrome 中加载速度非常慢。
看看网络,问题似乎是对于大多数 JSF 和 Richfaces 资源,浏览器会收到 304 响应,但最终获得这些资源需要很长时间(我说的是几分钟)。
我的 web.xml:
<context-param>
<description>
Set the max time in miliseconds set on the "Expires" header for a resource rendered by the default ResourceHandler.
</description>
<param-name>org.apache.myfaces.RESOURCE_MAX_TIME_EXPIRES</param-name>
<param-value>2592000000</param-value><!-- 30 Days -->
</context-param>
<!-- RichFaces -->
<context-param>
<description>Defines in seconds how long streamed back to browser resources can be cached.</description>
<param-name>org.ajax4jsf.DEFAULT_EXPIRE</param-name>
<param-value>2592000</param-value><!-- 30 Days -->
</context-param>
<context-param>
<param-name>org.richfaces.resourceOptimization.enabled</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
<context-param>
<!-- If org.richfaces.LoadScriptStrategy is set to ALL, this should be false -->
<param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
<param-value>false</param-value>
</context-param>
资源之一的示例请求/响应(Chrome)
Request URL:http://localhost/weblogicOMIA1003/APOMIA1003/faces/javax.faces.resource/calendar.js?ln=org.richfaces
Request Method:GET
Status Code:304 Not Modified
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:JSESSIONID=RTJDSDYGFNnmDSVLySxVMJBJyhhm2GKSLtwPXmLtllqy9xh1MJjY!1711646894
Host:10.42.100.123
If-Modified-Since:Wed, 17 Oct 2012 18:13:54 GMT
Referer:http://10.42.100.123/weblogicOMIA1003/APOMIA1003/faces/analytics/trends/BasicTrends.xhtml?NODEID=545&STATEID=USGVDATIKOO1.e.p.hlzjqo1s462
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36
Query String Parametersview sourceview URL encoded
ln:org.richfaces
Response Headersview source
X-Powered-By:Servlet/3.0 JSP/2.2
X-Powered-By:JSF/2.0
X-UA-Compatible:IE=edge