You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dariusz Wojtas <dw...@gmail.com> on 2006/12/04 09:28:15 UTC

[S2] TabbedPanel, static content from struts, If-Modified-Since

Hi

I have just built Struts 2.0.2 snapshot based on the latest svn code
(03 Dec 2006).
I can see huge improvement over the 2.0.1 code in tabbedPanel
handling, also the default css styles are much nicer.
But here are some questions about this:

1) Does it really need to download 500+ kB of javascript and related
code to display a set of empty tabs? Can it be compressed somehow? Any
switches for that?

2) Why does that javascript and related code get reloaded every time?
    I try to enter the page with tabs again (not forcing reload with SHIFT) and
    all that stuff is fetched again.
    Can it be something with http headers?
    The total amount of data that is sent is really frustrating me.

3) In addition to that I could observe 16 multiple requests for
       GET /myApp/struts/xhtml/styles.css HTTP/1.1
    to display single HTML page with 7 remote panels
    (test, all panels referring the same simple page with 1 test
sentence - nothing more).

4) It is not written anywhere in docs - but these tabs do not work if the S2
    application uses 'html' for action extension (overriding the default).
    Some of the resources returned by Struts for tabbedPanel also end
with 'html'
    and the struts controller sees a problem.
        GET /myApp/struts/dojo/src/widget/templates/TabContainer.html HTTP/1.1
    I can only see a stacktrace that such action is not defined in my app,
    dojo does not get such page and instead of tabs I can only see
error message
    in the browser.
    After I changed the extension for my actions to something else -
it started to work.
    But it took me 30 minutes to understand the problem.


About the browser-server conversation.
I could observe conversations like this (using LiveHttpHeaders):
The date on my system is: 4 gru 2006 00:09:33 GMT

BROWSER REQUEST:
--------------------
GET /myApp/struts/dojo/src/browser_debug.js HTTP/1.1
Host: myHost.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1)
Gecko/20061010 Firefox/2.0
Accept: */*
Accept-Language: pl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 300
Connection: keep-alive
Cookie: JSESSIONID=EAC57FC811A25266F50DE798A102A761;
__utma=220229530.66828090.1163407613.1163407613.1163410124.2;
__utmz=220229530.1163407613.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none)
If-Modified-Since: Pn, 4 gru 2006 00:09:33 GMT
Cache-Control: max-age=0

Tomcat (5.5.20) RESPONSE
------------------------------
HTTP/1.x 200 OK
Server: Apache-Coyote/1.1
Date: Mon, 04 Dec 2006 07:55:53 GMT
Expires: Wt, 5 gru 2006 08:55:54 GMT
Retry-After: Wt, 5 gru 2006 08:55:54 GMT
Cache-Control: public
Last-Modified: Pn, 4 gru 2006 00:09:33 GMT
Content-Type: text/javascript
Content-Length: 4861

The browser nicely asks for the content using the 'If-Modified-Since' header,
but Struts simply ignores it and resends the full javascript code
instead of the 'Not Modified' status. On the other side Struts allows
for caching it for 24 hours.

Also, the 'Date' headers contains date printed with EN locale, while
other date related headers (Expires, Retry-After, Last-Modified) print
date with PL locale (default for my machine). I am not sure where
these differences come from.

Can a check for 'If-Modified-Since' be added to the servlet that
returns all the static code inside Struts2?
Maybe even there could be some switch in struts.properties to specify
the time between 'Date' and 'Expires' for static content?


The overall experience is very positive, just these little-big annoyances ...

Darek

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] TabbedPanel, static content from struts, If-Modified-Since

Posted by Dariusz Wojtas <dw...@gmail.com>.
I posted a patch to WW-1536 that solves these date/if-modified-since issues.
Minor changes that affect only 1 method.
I believe it even simplified some of these things - and it fixes a bug.
Any chance to think about it (and if it makes sense) before releasing 2.0.2?
At least these headers ...

Dariusz Wojtas


On 12/5/06, Musachy Barroso <mb...@wfscorp.com> wrote:
> I think there should be two jira tickets, one with the Dojo stuff(I
> created one for that already), and another with the servlet/date stuff.
>
> On a side note, I created a custom profile and compiled Dojo(really
> easy) and everything worked fine, with caching and all, I will mention
> it on the dev list to see what other people think for 2.0.3.
>
> musachy
>
> Dariusz Wojtas wrote:
> > Hello again,
> >
> > The static content is served by the main Struts2 Filter:
> >  org.apache.struts2.dispatcher.FilterDispatcher
> > method:
> >  findStaticResource(String, HttpServletResponse)
> >
> >
> > 1) The response headers in non english-locale
> > ---------------------------------------
> > The (possible) issue with date headers in response comes from
> > the fact that this method does not use
> >   response.setDateHeader(name, value);
> > but
> >   response.setHeader(name, value);
> > instead.
> > Possibly it is done this way to improve performance of generating headers
> > because it creates a SimpleDateFormat with the correct pattern.
> > But here are possible problems:
> > a) the SimpleDateFormat uses default locale (in my case Polish)
> >    and the output does not comply the required standard
> >      RFC 1123, chapter 5.2.14  "RFC-822 Date and Time Specification"
> >      RFC 822, section 5.  "DATE AND TIME SPECIFICATION"
> >
> >    If the filter wants to format dates on it's own, it should create
> >    formatter with the Locale.ENGLISH (there exists constructor that
> > allows it).
> >
> >    Sample response with locale PL
> >     Pn, 04 gru 2006 07:55:53 GMT
> >    while it should be:
> >     Mon, 04 Dec 2006 07:55:53 GMT
> >
> >
> > b) [POSSIBLE BUG] as the SimpleDateFormat javadoc states (since JDK 1.4),
> >    it is not safe if multiple threads are accessing the same formatter.
> >    This may really lead to some inconsistencies and I would treat it
> > as a bug.
> >
> >
> > 2) If-Modified-Since
> > ---------------------------------------
> > This header should be evaluated in the same method:
> > findStaticResource(String, HttpServletResponse)
> > A little extra condition and the issue with resending full content
> > all-the-time is fixed.
> > I could send a patch if there is some interest in it.
> >
> > Best regards
> >  Dariusz Wojtas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] TabbedPanel, static content from struts, If-Modified-Since

Posted by Musachy Barroso <mb...@wfscorp.com>.
I think there should be two jira tickets, one with the Dojo stuff(I 
created one for that already), and another with the servlet/date stuff.

On a side note, I created a custom profile and compiled Dojo(really 
easy) and everything worked fine, with caching and all, I will mention 
it on the dev list to see what other people think for 2.0.3.

musachy

Dariusz Wojtas wrote:
> Hello again,
>
> The static content is served by the main Struts2 Filter:
>  org.apache.struts2.dispatcher.FilterDispatcher
> method:
>  findStaticResource(String, HttpServletResponse)
>
>
> 1) The response headers in non english-locale
> ---------------------------------------
> The (possible) issue with date headers in response comes from
> the fact that this method does not use
>   response.setDateHeader(name, value);
> but
>   response.setHeader(name, value);
> instead.
> Possibly it is done this way to improve performance of generating headers
> because it creates a SimpleDateFormat with the correct pattern.
> But here are possible problems:
> a) the SimpleDateFormat uses default locale (in my case Polish)
>    and the output does not comply the required standard
>      RFC 1123, chapter 5.2.14  "RFC-822 Date and Time Specification"
>      RFC 822, section 5.  "DATE AND TIME SPECIFICATION"
>
>    If the filter wants to format dates on it's own, it should create
>    formatter with the Locale.ENGLISH (there exists constructor that 
> allows it).
>
>    Sample response with locale PL
>     Pn, 04 gru 2006 07:55:53 GMT
>    while it should be:
>     Mon, 04 Dec 2006 07:55:53 GMT
>
>
> b) [POSSIBLE BUG] as the SimpleDateFormat javadoc states (since JDK 1.4),
>    it is not safe if multiple threads are accessing the same formatter.
>    This may really lead to some inconsistencies and I would treat it 
> as a bug.
>
>
> 2) If-Modified-Since
> ---------------------------------------
> This header should be evaluated in the same method:
> findStaticResource(String, HttpServletResponse)
> A little extra condition and the issue with resending full content
> all-the-time is fixed.
> I could send a patch if there is some interest in it.
>
> Best regards
>  Dariusz Wojtas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] TabbedPanel, static content from struts, If-Modified-Since

Posted by Dariusz Wojtas <dw...@gmail.com>.
Hello again,

The static content is served by the main Struts2 Filter:
  org.apache.struts2.dispatcher.FilterDispatcher
method:
  findStaticResource(String, HttpServletResponse)


1) The response headers in non english-locale
---------------------------------------
The (possible) issue with date headers in response comes from
the fact that this method does not use
   response.setDateHeader(name, value);
but
   response.setHeader(name, value);
instead.
Possibly it is done this way to improve performance of generating headers
because it creates a SimpleDateFormat with the correct pattern.
But here are possible problems:
 a) the SimpleDateFormat uses default locale (in my case Polish)
    and the output does not comply the required standard
      RFC 1123, chapter 5.2.14  "RFC-822 Date and Time Specification"
      RFC 822, section 5.  "DATE AND TIME SPECIFICATION"

    If the filter wants to format dates on it's own, it should create
    formatter with the Locale.ENGLISH (there exists constructor that allows it).

    Sample response with locale PL
     Pn, 04 gru 2006 07:55:53 GMT
    while it should be:
     Mon, 04 Dec 2006 07:55:53 GMT


 b) [POSSIBLE BUG] as the SimpleDateFormat javadoc states (since JDK 1.4),
    it is not safe if multiple threads are accessing the same formatter.
    This may really lead to some inconsistencies and I would treat it as a bug.


2) If-Modified-Since
---------------------------------------
This header should be evaluated in the same method:
findStaticResource(String, HttpServletResponse)
A little extra condition and the issue with resending full content
all-the-time is fixed.
I could send a patch if there is some interest in it.

Best regards
  Dariusz Wojtas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] TabbedPanel, static content from struts, If-Modified-Since

Posted by Musachy Barroso <mb...@wfscorp.com>.
In short, I don't know the answer to any of your questions :), but I 
will dig into them. I created a jira ticket for 1-4. 
(https://issues.apache.org/struts/browse/WW-1536). As for the servlet 
question, the other guys probably know.

regards
musachy

Dariusz Wojtas wrote:
> Hi
>
> I have just built Struts 2.0.2 snapshot based on the latest svn code
> (03 Dec 2006).
> I can see huge improvement over the 2.0.1 code in tabbedPanel
> handling, also the default css styles are much nicer.
> But here are some questions about this:
>
> 1) Does it really need to download 500+ kB of javascript and related
> code to display a set of empty tabs? Can it be compressed somehow? Any
> switches for that?
>
> 2) Why does that javascript and related code get reloaded every time?
>    I try to enter the page with tabs again (not forcing reload with 
> SHIFT) and
>    all that stuff is fetched again.
>    Can it be something with http headers?
>    The total amount of data that is sent is really frustrating me.
>
> 3) In addition to that I could observe 16 multiple requests for
>       GET /myApp/struts/xhtml/styles.css HTTP/1.1
>    to display single HTML page with 7 remote panels
>    (test, all panels referring the same simple page with 1 test
> sentence - nothing more).
>
> 4) It is not written anywhere in docs - but these tabs do not work if 
> the S2
>    application uses 'html' for action extension (overriding the default).
>    Some of the resources returned by Struts for tabbedPanel also end
> with 'html'
>    and the struts controller sees a problem.
>        GET /myApp/struts/dojo/src/widget/templates/TabContainer.html 
> HTTP/1.1
>    I can only see a stacktrace that such action is not defined in my app,
>    dojo does not get such page and instead of tabs I can only see
> error message
>    in the browser.
>    After I changed the extension for my actions to something else -
> it started to work.
>    But it took me 30 minutes to understand the problem.
>
>
> About the browser-server conversation.
> I could observe conversations like this (using LiveHttpHeaders):
> The date on my system is: 4 gru 2006 00:09:33 GMT
>
> BROWSER REQUEST:
> --------------------
> GET /myApp/struts/dojo/src/browser_debug.js HTTP/1.1
> Host: myHost.com
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1)
> Gecko/20061010 Firefox/2.0
> Accept: */*
> Accept-Language: pl,en-us;q=0.7,en;q=0.3
> Accept-Encoding: gzip,deflate
> Accept-Charset: UTF-8,*
> Keep-Alive: 300
> Connection: keep-alive
> Cookie: JSESSIONID=EAC57FC811A25266F50DE798A102A761;
> __utma=220229530.66828090.1163407613.1163407613.1163410124.2;
> __utmz=220229530.1163407613.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none) 
>
> If-Modified-Since: Pn, 4 gru 2006 00:09:33 GMT
> Cache-Control: max-age=0
>
> Tomcat (5.5.20) RESPONSE
> ------------------------------
> HTTP/1.x 200 OK
> Server: Apache-Coyote/1.1
> Date: Mon, 04 Dec 2006 07:55:53 GMT
> Expires: Wt, 5 gru 2006 08:55:54 GMT
> Retry-After: Wt, 5 gru 2006 08:55:54 GMT
> Cache-Control: public
> Last-Modified: Pn, 4 gru 2006 00:09:33 GMT
> Content-Type: text/javascript
> Content-Length: 4861
>
> The browser nicely asks for the content using the 'If-Modified-Since' 
> header,
> but Struts simply ignores it and resends the full javascript code
> instead of the 'Not Modified' status. On the other side Struts allows
> for caching it for 24 hours.
>
> Also, the 'Date' headers contains date printed with EN locale, while
> other date related headers (Expires, Retry-After, Last-Modified) print
> date with PL locale (default for my machine). I am not sure where
> these differences come from.
>
> Can a check for 'If-Modified-Since' be added to the servlet that
> returns all the static code inside Struts2?
> Maybe even there could be some switch in struts.properties to specify
> the time between 'Date' and 'Expires' for static content?
>
>
> The overall experience is very positive, just these little-big 
> annoyances ...
>
> Darek
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] TabbedPanel, static content from struts, If-Modified-Since

Posted by Musachy Barroso <mb...@wfscorp.com>.
I found this:

"Dojo also provides a mechanism for building "profiles"; the build 
system takes as input a list of packages, and uses Apache Ant 
<http://en.wikipedia.org/wiki/Apache_Ant> to create a single compressed 
JavaScript file containing those packages and all their dependencies. 
This allows all necessary code to be loaded and initialized at once, and 
permits caching <http://en.wikipedia.org/wiki/Cache> of the code (most 
web browsers <http://en.wikipedia.org/wiki/Web_browser> do not cache 
files loaded via XMLHttpRequest). Pre-built profiles for some common use 
cases are available for download from the same location as the full 
toolkit."

here: http://en.wikipedia.org/wiki/Dojo_Toolkit

To create profiles(get all you need in one file...which can be cached): 
ttp://manual.dojotoolkit.org/WikiHome/DojoDotBook/Book94
To compress the js: http://dojotoolkit.org/docs/compressor_system.html

I would be nice to have a profile with the stuff used by S2, I have to 
check if there is any pre-built profile that we can use.

musachy


Dariusz Wojtas wrote:
> Hi
>
> I have just built Struts 2.0.2 snapshot based on the latest svn code
> (03 Dec 2006).
> I can see huge improvement over the 2.0.1 code in tabbedPanel
> handling, also the default css styles are much nicer.
> But here are some questions about this:
>
> 1) Does it really need to download 500+ kB of javascript and related
> code to display a set of empty tabs? Can it be compressed somehow? Any
> switches for that?
>
> 2) Why does that javascript and related code get reloaded every time?
>    I try to enter the page with tabs again (not forcing reload with 
> SHIFT) and
>    all that stuff is fetched again.
>    Can it be something with http headers?
>    The total amount of data that is sent is really frustrating me.
>
> 3) In addition to that I could observe 16 multiple requests for
>       GET /myApp/struts/xhtml/styles.css HTTP/1.1
>    to display single HTML page with 7 remote panels
>    (test, all panels referring the same simple page with 1 test
> sentence - nothing more).
>
> 4) It is not written anywhere in docs - but these tabs do not work if 
> the S2
>    application uses 'html' for action extension (overriding the default).
>    Some of the resources returned by Struts for tabbedPanel also end
> with 'html'
>    and the struts controller sees a problem.
>        GET /myApp/struts/dojo/src/widget/templates/TabContainer.html 
> HTTP/1.1
>    I can only see a stacktrace that such action is not defined in my app,
>    dojo does not get such page and instead of tabs I can only see
> error message
>    in the browser.
>    After I changed the extension for my actions to something else -
> it started to work.
>    But it took me 30 minutes to understand the problem.
>
>
> About the browser-server conversation.
> I could observe conversations like this (using LiveHttpHeaders):
> The date on my system is: 4 gru 2006 00:09:33 GMT
>
> BROWSER REQUEST:
> --------------------
> GET /myApp/struts/dojo/src/browser_debug.js HTTP/1.1
> Host: myHost.com
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.8.1)
> Gecko/20061010 Firefox/2.0
> Accept: */*
> Accept-Language: pl,en-us;q=0.7,en;q=0.3
> Accept-Encoding: gzip,deflate
> Accept-Charset: UTF-8,*
> Keep-Alive: 300
> Connection: keep-alive
> Cookie: JSESSIONID=EAC57FC811A25266F50DE798A102A761;
> __utma=220229530.66828090.1163407613.1163407613.1163410124.2;
> __utmz=220229530.1163407613.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none) 
>
> If-Modified-Since: Pn, 4 gru 2006 00:09:33 GMT
> Cache-Control: max-age=0
>
> Tomcat (5.5.20) RESPONSE
> ------------------------------
> HTTP/1.x 200 OK
> Server: Apache-Coyote/1.1
> Date: Mon, 04 Dec 2006 07:55:53 GMT
> Expires: Wt, 5 gru 2006 08:55:54 GMT
> Retry-After: Wt, 5 gru 2006 08:55:54 GMT
> Cache-Control: public
> Last-Modified: Pn, 4 gru 2006 00:09:33 GMT
> Content-Type: text/javascript
> Content-Length: 4861
>
> The browser nicely asks for the content using the 'If-Modified-Since' 
> header,
> but Struts simply ignores it and resends the full javascript code
> instead of the 'Not Modified' status. On the other side Struts allows
> for caching it for 24 hours.
>
> Also, the 'Date' headers contains date printed with EN locale, while
> other date related headers (Expires, Retry-After, Last-Modified) print
> date with PL locale (default for my machine). I am not sure where
> these differences come from.
>
> Can a check for 'If-Modified-Since' be added to the servlet that
> returns all the static code inside Struts2?
> Maybe even there could be some switch in struts.properties to specify
> the time between 'Date' and 'Expires' for static content?
>
>
> The overall experience is very positive, just these little-big 
> annoyances ...
>
> Darek
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org