-
1. Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
ilya_shaikovsky Apr 18, 2011 4:37 AM (in response to nikh123123)please watch that issues:
-
2. Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
nikh123123 Apr 18, 2011 5:44 AM (in response to ilya_shaikovsky)Thanks @Ilya for clarifying on that. Is there any workaround with which we can minimize the JS/CSS generated by richfaces, until the said JIRA tasks are completed?
Also, the readme in Richfaces 4 final bundle recommends use of caching such as ehcache. Can someone help me out on how we can configure ehcache for JSF?
-
3. Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
nikh123123 Apr 26, 2011 9:48 AM (in response to nikh123123)Lookin at the JIRA, the tasks are targeted to be completed in 4.1.0.Milestone1 and 4.Future .Could anyone shed light to when would these be available to the community? Because without these things, we cannot really use Richfaces in production, can we?
-
4. Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
entestat May 11, 2011 6:51 AM (in response to nikh123123)Hi guys,
I've made the workaround, so I share it here. It improves page load time dramatically.
All you need is to download this two classes:
http://entestat.com/pub/figlo/Collector.java
and
http://entestat.com/pub/figlo/ScriptCollectorFilter.java
you will also need the Apache HTTP Client (http://hc.apache.org/downloads.cgi).
It's also necessary to put following lines to web.xml:
<filter>
<filter-name>Figlo</filter-name>
<filter-class>figlo.ScriptCollectorFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Figlo</filter-name>
<url-pattern>/</url-pattern>
<url-pattern>*.html</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Collector</servlet-name>
<servlet-class>figlo.Collector</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Collector</servlet-name>
<url-pattern>/collector/*</url-pattern>
</servlet-mapping>
The code is draft-quality (but works fine), so you should review it before usage. Especially you should verify variable named 'self' in ScriptCollectorFilter.java, which contains the address where server is able to connect with self.
It works as follows:
1. The filter is reading the page header.
2. The <script> and <link> tags are removed
3. The single <script> and the single <link> tags are attached at the end of the header content (which points to Collector servlet).
3. If removed scripts and css-files are not cached yet, filter is downloading them and pushing them into Collector caches.
-
5. Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
nikh123123 May 11, 2011 9:55 AM (in response to entestat)Thanks a TON @Maciej! Like a million tons for your efforts and for your sharing spirit! We were trying on every aspect possible and richfaces's internal css and js were something, we were not able to optimize manually. I'll try your code as soon as possible and get back!
-
6. Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
entestat May 12, 2011 1:01 PM (in response to nikh123123)I had upload new version of classes with few bugfixes, so if you will make any test, please download the newst files.
Regards!
-
7. Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
ilya_shaikovsky May 12, 2011 1:40 PM (in response to entestat)That looks great especially considering that there is still no adjusted plans for having it out of the box. B.t.w. if you will add that to jira as workaround that would help a lot.
-
8. Re: Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
entestat May 14, 2011 6:50 PM (in response to ilya_shaikovsky)Today I added support for gzip content-encoding for output files. This reduces output size 3-4 times, and because compressed content is cached by Collector class, this also reduces CPU usage (time elapsed till first byte of response comes is shorter 1.5 - 2 times) .
@Ilya - I noticed, that you've alredy add link to this thread to jira.
Regards!
EDIT: Newer version uploaded with one bug fixed (when jsession is send by URL it's necessary to remove it from scripts adresses)
-
9. Re: Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
nikh123123 Jun 1, 2011 11:03 AM (in response to entestat)Hi Maciej!
I've been trying you code, but in my case it seems that the filter and servlet is never executed. I tried with simple println statements in the doGet and doPost of servlet and also in the doFilter method of filter. I've made the self related changes and have also added correct entries in the web.xml. What could be the issue here?
-
10. Re: Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
entestat Jun 1, 2011 12:55 PM (in response to nikh123123)@Nikil - Im guessing that "url-pattern" is not set properly to your url mappings. In the configuration that I had sent only "/" and "*.html" are affected by the filter. If you are using another mapping (ex. *.jsf) some changes should be done in filter-mapping section and also in 11th line of doFilter function if(uri.endsWith(".html") || uri.length() < 2) should be changed to match your urls mapping.
Could you send me your web.xml? My address is: maciej.kraus(at)entestat.com. If I found something that may help I'll send it here.
-
11. Re: Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
nikh123123 Jun 8, 2011 1:12 AM (in response to entestat)@Maciej: I could solve it, thanks! Yes I had to adjust the URL pattern, and as I'm on https i had to make some changes to the connection part in ScriptCollectorFilter. Also, as I was referring to the httpclient-4.1.1.jar, had to make some changes to the DateUtils code. Since the DateUtils are in the org.apache.http.impl.cookie.DateUtils package now and the DateUtils.parseDate method takes String[] as params rather than a List<String>. And the code works just fine
When the user tries to access the page for the first time, it takes a little longer to load the page. But for the subsequent requests, it speeds up a lot.
-
12. Re: Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
tchoesang Sep 9, 2011 4:24 AM (in response to entestat)@Maciej: Thank you very much for your contribution of a much needed feature in RF4.
I am running into a problem with compression of richfaces resources and you might able to give me a hint.
First of all, the servlet and the filter works marvelously on all resources except Richfaces.
Reason: Richfaces resources source looks like this: http://localhost:8080/myproject/rfRes/skinning.ecss.jsf?db=eAHL6rC8BQAEkAIG
The Server returns an empty file when the filter is turned on and when the filter is commented out, the server correctly returns the respective file.
I found a workaround for rfRes by replacing it with javax.faces.resource but the problem re-emerges when certain parts of page is loaded later from server through AJAX.
Any clue, why when Filter is turned on, the path with rfRes is not reachable or returns empty?
Richfaces 4.1.0-M1
Primefaces 2.2.1
Spring 3.0.6
JSF 2.1.2
Attached is my web.xml
-
web.xml 4.6 KB
-
-
13. Re: Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
jmiguel77 Dec 8, 2011 4:56 PM (in response to ilya_shaikovsky)i am using 4.1.0.20111101-M4 bom, in my project, but this feature is still not supported. I have this in my web.xml:
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadScriptStrategy</param-name>
<param-value>ALL</param-value>
</context-param>
but the stylesheets are still being loaded on demand;
-
14. Re: Richfaces 4 availability of COMPRESS_SCRIPT,LoadStyleStrategy and LoadScriptStrategy
ravi.jrk Dec 9, 2011 12:00 PM (in response to tchoesang)Hi choesang,
Did you find any work around for inlcuding the richfaces files? plz let me know if you have any update on this.
Thanks & Regards
Ravi