Skip to main content

YSlow - Grade A - may not equate to a high performance website

YSlow, an add-on plugin for Firebug, a must have tool for all web developers concerned about performance of their website. As shown in the picture below, analysis using Firebug reveals all the the performance bottlenecks.



YSlow, add-on plugin used along with Firebug, gives more detailed analysis and suggests useful tips to improve the performance. It has a grading system on a scale of A to F, A being the highest performer. Given below is the snapshot of its report run on this blog.



This blog got a grade of 'B' with overall performance rating of 80%. From the report we can see that non-usage of CDN, DNS lookups, inline and uncompressed javascripts and css files brought down the performance score. There are number of techniques and tips provided on YSlow website, that helps to improve the grades.

Developers working on frameworks like Grails or JSF may find some practical difficulties in implementing some of the techniques listed.
1) Combining all javascript files and css files
2) Adding all the script files (*.js) files at the bottom of the page.

When using grails plugin, the plugin may require few css files and js files of its own. Similarly, when using RichFaces for JSF the RichFaces framework may include number of js and css files depending on the component used. The idea behind is to use only the scripts that are absolutely necessary to run the Richfaces component or a grails plugin. But when we use more than one component we will have to face the burden of loading multiple script files. Obviously, this impacts the performance and thus a low YSlow grade. Incase of RichFaces, JSF library, we could use an inbuilt optimizing technique provided by the framework.
By adding the following context parameters to the deployment descriptor, web.xml, we will be able to combine all the scripts used in the richfaces component. I wish there is similar technique for Grails applications as well.


<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>





For web applications, that donot use any of the frameworks, where developer have complete control of the content (html, css, scripts, images et) it is easy not very difficult to get graded as "A" by YSlow. However, I noticed the tool deosn't take into account - the response time from the server. As long as as the tool's prescribed criteria is met, we can sit on Grade - A. In an instance where content from the server take about 10secs to load and if the content content-encoding is gzip, YTool gives it an A-Grade. (Assuming all the other rules are satifisfied by the application).

Therefore, in my opinion, rather than using the tool as a benchmark in comparing various competing websites it should be used to identifify all the performance bottlenecks in webapplications and take corrective actions. In my future posts I will be able to post some techniques used to get better grade when a combination of the following components are used in a web application. An Apache server acting as a proxy to a Tomcat application server using AJP connector. The database used in the tuning excercise is MySql.

Comments

Popular posts from this blog

Grails - cross-field Date validation

Often we run into domain classes with date fields. If the domain class has two datefields, startDate and endDate, and the rule for a valid combination is "endDate to be greater than startDate", how do we handle? I listed below two of the options, either using domain level constraints or using the domain classes. Option 1: Using domain constraints. Let us take a sample Grails Domain class class Student{ String name String school Date startDate Date endDate } Add the following constraints to enforce validation rules where name, school, startDate cannot be blank and endDate if present should be greater than startDate.

Grails - Querying complex associations

Criteria class allows performing complex searches on grails objects. There are number of shortcut methods for performing queries but these methods have limitations in terms of number of conditions used in "where clauses". Traditional sql "joins" are not possible as shown in some of the Grails "Finder" methods shown below. Sample 1: def list = AccountTransaction.findAllByCompanyCodeAndVoucherDateBetween(branch, fromDate, toDate, params) Sample 2: def list = AccountTransaction.findAllByCompanyCodeAndVoucherDateGreaterThanEquals(branch, fromDate, params) Sample 3: def list = AccountTransaction.findAllByCompanyCodeAndTransGroup(branch, group, params) "params" contains attributes related to sorting, paging etc. It is very easy to use finder methods but when you want to filter objects by more conditions we need to look for alternatives. For understanding the relationships used in this sample, I listed the grails domain classes. class TransactionTyp

Implementing advanced sort in Grails

The "list" pages generated by inbuilt scaffolding/template features of grails have pagination and sorting features. However, if the domain object displayed in the list is a nested object having another domain object as a property, you may notice that sort is not enabled for that field. Boiler plate code for the header of the list is shown below. As you would have noticed few columns have sortable columns automatically generated by Grails command, generate-all or generate-views. The properties 'partyAccount' and 'bankAccount' in this sample are domain classes nested in the domain class 'partyTransaction'. We could convert them to sortable columns by using the tag g:sortableColum