If the number 1 rule for making faster websites is to "Minimize HTTP Requests", then, let's try it.
On this site, almost all pages are served entirely from memcache. Django renders the template with the database content and the generated HTML is cached. So I thought I insert a little post processing script that converts all <img src="...something...">
into <img src="data:image/png;base64,iVBORw0KGgo...">
which basic means the HTML gets as fat as the sum of all referenced images combined.
It's either 10Kb HTML followed by (rougly) 10 x 30Kb images or it's 300Kb HTML and 0 images. The result is here: https://www.peterbe.com/about2 (open and view source)
You can read more about the Data URI scheme here if you're not familiar with how it works.
The code is a hack but that's after all what a personal web site is all about :)
So, how much slower is it to serve? Well, actual server-side render time is obviously slower but it's a process you only have to do a small fraction of the total time since the HTML can be nicely cached.
Running..
ab -n 1000 -c 10 https://www.peterbe.com/about
BEFORE:
Document Path: /about Document Length: 12512 bytes Concurrency Level: 10 Time taken for tests: 0.314 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 12779000 bytes HTML transferred: 12512000 bytes Requests per second: 3181.36 [#/sec] (mean) Time per request: 3.143 [ms] (mean) Time per request: 0.314 [ms] (mean, across all concurrent requests) Transfer rate: 39701.75 [Kbytes/sec] received
AFTER:
Document Path: /about2 Document Length: 306965 bytes Concurrency Level: 10 Time taken for tests: 1.089 seconds Complete requests: 1000 Failed requests: 0 Write errors: 0 Total transferred: 307117000 bytes HTML transferred: 306965000 bytes Requests per second: 918.60 [#/sec] (mean) Time per request: 10.886 [ms] (mean) Time per request: 1.089 [ms] (mean, across all concurrent requests) Transfer rate: 275505.06 [Kbytes/sec] received
So, it's basically 292Mb transferred instead of 12Mb in the test and the requests per second is a third of what it used to be. But it's not too bad. And with web site optimization, what matters is the individual user's impression, not how much or how little the server can serve multiple users.
Next, how does the waterfall of this look?