You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Shuai Zheng <zh...@gmail.com> on 2007/02/28 11:34:21 UTC

Some tips to help load page faster

Dear All,

Just optimize my small project which is using struts 2.0.6.  Here is
something that may help to get the faster speed when load a page:

1, Use the default setting of Struts.properties unless you really know the
meaning of the parameter. For example: set
struts.configuration.xml.reloadto true in the properties file will
give another extra
0.3 second to when loading a page (I copy this parameter from showcase and
suffered by it).

2, When you need to display a collection with a lot of items in it. Avoid to
using OGNL. For example:
There is a list in my page, which includes around 800+ items, I want to show
them in a select list. Previously I get it from database by Hibernate and
directly pass the result list to the component, this will cause 0.8-1 second
to finish construct this select component.
        <s:select
            list="prodList"
            multiple="true"
            listKey="idkey"
            listValue="prodName"
            />
Then I loop the list in the java code first and convert it into a
Map<String, String>, and pass the map to the select.
        <s:select list="prodMap"  multiple="true" />
This will save 0.5 second to construct this select component on the page. If
you need to use a complex OGNL expression, it will be even slower, You can
loop a complex OGNL for 100+ times in the code comparing with normal java
code, then you will experience it :).
The OGNL is very convenience but it will impact the performance sliently.

3, <s:head/>. This tag will give another 500ms when load the page because it
needs to load the dojo script. This is nothing about the server side, the
cost is on the client side. You can save the page locally and open it by FF,
it is still slow(comparing without this tag). In most pages, this tag is
useless (unless you want to write your own ajax code under dojo framework).
I try to use my own code to replace it even I need some dojo functionality.

4, This article is very useful:
http://wiki.opensymphony.com/display/WW/Performance+Tuning. It is surely you
must copy out all the freemarker template into WEB_APP. Here I find out one
small thing:  after put alll the template to WEB_APP, you can also copy the
template/simple/hidden.ftl to template/xhtml/hidden.ftl because by default
hidden tag will use xhtml as theme, and this will allow the freemarker to
cache it properly.
BTW: I try to find out, but honestly can't experience different between
basic and default interceptor stack on performance in my project.

cheers:)

Regards,

Zheng Shuai