Issue link: https://read.uberflip.com/i/1146286
eBay | 117 Rule 1: Make Fewer HTTP Requests The eBay page has 10 scripts and 3 stylesheets. A simple fix would be to use the combination technique described in Chapter 1. Four of the scripts are loaded close together at the top of the page, and three are at the bottom of the page. These should be combined into a top script and a footer script, reducing 10 scripts to 5. The three stylesheets are all loaded close together and should also be combined. Rule 3: Add an Expires Header One script and one stylesheet have an Expires header that is only nine hours in the future. According to the Last-Modified date, the stylesheet hasn't been modi- fied in 3 days, and the script in 24 days. These are likely assets that change over time, but given the number of users of the site, it would be better to use a far future Expires header to make these files cacheable. Additionally, there are five IFrames without an Expires header. These are used to insert ad images, some of which don't have an Expires header as well. Rule 9: Reduce DNS Lookups Nine different domains are used in the eBay page. Typically, a domain count this high includes several domains from third-party advertisers, but in this case, there are seven domains related to eBay, and only two used by third-party advertisers. Rule 13: ETags—Configure ETags Fifty-two components are served from IIS using the default ETag. As explained in Chapter 13, this causes components to be downloaded much more frequently than necessary. This is exacerbated by the fact that these components have an expiration date that is at most 45 days in the future. As the components become stale and the conditional GET request is made, the ETag is likely to spoil the chances of getting a fast "304 Not Modified" response, and instead end up send- ing back the entire component even though it already resides on the user's disk. The use of IFrames to serve ads is worth discussing. IFrames achieve a clear separa- tion between ads and the actual web page, allowing those teams and systems to work independently. The downside is that each IFrame is an additional HTTP request that typically (as in this case) is not cached. Using IFrames to serve ads is further justified because ads often contain their own JavaScript code. If the ad content is coming from a third party and includes Java- Script, placing it in an IFrame sandboxes the JavaScript code, resulting in greater security (the third party's JavaScript code cannot access the web page's namespace). However, in eBay's page, the ads served in IFrames include no JavaScript. Further- more, only one contains third-party content. Inserting the ads during HTML page generation would eliminate these five HTTP requests for IFrames. An additional improvement would be to split the bulk of the images across two host- names. Thirty-six of the 41 images come from http://pics.ebaystatic.com. In HTTP/1.1, only two components per hostname are downloaded in parallel (see Chapter 6). This has a negative effect on the degree of HTTP request parallelization (see Figure 15-11).

