Source: Ajax data station
Digg.com, which is known to surpass Slashdot, is a typical Ajax application. Its homepage uses the prototype framework and scriptaculous extension. A good idea is to collect statistics on the total number of bytes of JavaScript and CSS files downloaded when loading the digg.com homepage. It is found that HTML + JS + CSS has more than 250 kb, so Digg is proposed: javascript overload? . Zimbra provides some Optimization Methods for this problem: Ajax and CSS optimization. The main points are as follows:
Integrate multiple JS or CSS files into one file to reduce the number of HTTP connections. Use a jsmin-like tool to remove comments, blank spaces, and extra blank lines to reduce the amount of data transmitted over the network, after the Web server application gzip compression zimbra is optimized using the above method, the test shows that the bandwidth is reduced by more than 50%.
In our current and future Ajax development, we will certainly encounter performance problems similar to digg.com. Zimbra solutions are available for reference. I think HTTP compression is the most important part of Ajax optimization. We can apply the default mechanism provided by web server, such as the compression option provided by tomcat5.x in connector configuration. A typical connector configuration is as follows:
<Connector
Port = "8080" maxhttpheadersize = "8192" maxthreads = "150" minsparethreads = "25"
Maxsparethreads = "75" enablelookups = "false" redirectport = "8443"
Acceptcount = "100" connectiontimeout = "20000" disableuploadtimeout = "true"
Compression = "on"
Compressablemimetype = "text/html, text/XML, text/plain, text/JavaScript, text/CSS"
/>
The preceding configuration uses the compression attribute to activate compression, and then uses the compressablemimetype attribute to set the MIME type for application compression. The most famous Apache server also provides mod_deflate and other modules to provide similar compression configurations.
In addition, the compression function can be provided by calling the API programming provided by Web server. For example, Java is also widely used to provide a gzipfilter application for servlet containers.