sleep.cgi
While building the examples of this phenomenon, I developed a tool that I've found extremely useful for showing how delayed components affect web pages: sleep.cgi. It's a simple Perl CGI program that takes the following parameters:
sleepHow long (in seconds) the response should be delayed. The default is
0.typeThe type of component to return. Possible values are
gif,js,css,html, andswf. The default value isgif.expiresOne of three values:
−1(returns anExpiresheader in the past),0(noExpiresheader is returned), and1(returns anExpiresheader in the future). The default is1.lastA value of
−1returns aLast-Modifiedheader with a date equal to the file's timestamp. A value of0results in noLast-Modifiedheader being returned. The default is−1.redirA value of
1causes a 302 response that redirects back to the exact same URL withredir=1removed.
The first example requires some slow images and a slow stylesheet. Those are achieved with the following requests to sleep.cgi:
<img src="/bin/sleep.cgi?type=gif&sleep=2&expires=-1&last=0"> <link rel="stylesheet" href="/bin/sleep.cgi?type=css&sleep=1&expires=-1&last=0">
Both the image and stylesheet use the expires=−1 option to get a response that has
an Expires header in the past. This prevents the components from being cached so that you can run the test repeatedly and get the same experience each time (I also add a unique timestamp to each component's URL to further prevent caching). In order to reduce the variables ...