YSlow Rules and Tomcat 5.5 SSL
A few weeks ago I attended The Rich Web Experience where I went to talks by Scott Davis and Nathaniel Schutta and heard about using YSlow to measure how well your web application performs. Of course I rushed right back to the office to check my current project's grade and implement as many of the performance enhancing techniques as I could. My application is running in Tomcat 5.5 over SSL. As it turned out this posed an unexpected challenge and in the end the solution was trickier than I anticipated. In case anyone else is in the same boat I'll reference the helpful article I found and summarize what I did to improve my grade.
response.setHeader("Expires", "Wed, 21 Oct 2009 11:49:28 GMT");
To be safe, I actually set the expires header to be one day after the current time because I read that if you set it too far in the future some browsers may reject it. Well, the filter did change the expires header but according to Firebug, Tomcat kept going back to the server to download the files anyway. The problem was a pragma no-cache header put in by Tomcat for some reason. This appears to trump the expires header. After some failed attempts to get rid of that pesky header I found this article which prompted me to add the following to my context.XML file.
<Valve className="org.apache.catalina.authenticator.SSLAuthenticator" disableProxyCaching="false" />
This solved my caching problem.
After performing these fairly simple modifications I've noticed a big improvement in performance. The user hits the home page and the browser downloads two extra minified files and a few images. Then for the rest of the day users are just loading dynamic HTML and taking the rest from cache. My only remaining task is to make use of a content delivery network or something like it for the static content. That ought to raise my B grade to an A! Thanks Firebug and YSlow!!!
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)