Skip to content

24 ways to impress your friends

Vote up?

Sripathi Krishnan

@Matt

More info on the redirect to sub-domain approach :

Step 1 : The first trick is to use WURFL (http://wurfl.sourceforge.net/). WURFL is a database that maps user agent strings to device capabilities. This means you can figure out the device or browsers aspect ratio server side on the first request.

Step 2 : Next, figure out how many different image resolutions you want to support, and then create a sub-domain for each resolution. Typical would be mobile, tablet, wired etc. But you are free to create as many sub-domains you want.

Step 3 : Then, redirect the user to the appropriate sub-domain on the first request.

Step 4 : Finally, in Apache, create virtual hosts for each sub-domain. So Apache will serve both m.example.com/path/to/img.png and t.example.com/path/to/img.png from different folders. No PHP required. Also, since the URL is unique, you can put strong cache headers.