I recently setup an AWS S3 account and hosted a static site there. I've setup one bucket for the 'www.example.com' and one for the apex domain 'example.com'.

The 'www.example.com' bucket redirects to the 'example.com' bucket. I have also setup a Cloudflare service which forces https on the domain.

So the chain is: http:// www.example.com -> http:// example.com -> https:// example.com

Furthermore, I am leveraging CloudFront to distribute content globally to help reduce S3 costs. I've opted to not go the Route53 route, due to costs.

I'm wondering what the performance implications are, in terms of content delivery, as well as what the implications are relating to S3 resource costs, does each request(as per the chain above) equate to a GET.

Is there a better and/or more efficient way of doing this, relating to both cost and performance ? What are best practises to follow in this regard.

up vote 1 down vote accepted

Double redirects are less efficient:

  • The browser makes a GET request for each
  • Each hostname (or subdomain) requires a separated DNS lookup.

In your chain you will have:

  • 3 GET requests
  • Two DNS lookups (HTTP and HTTPS use the same DNS lookup for example.com)

If it is convenient, it would be better to configure http:// www.example.com to redirect directly to https:// example.com.

How much worse is it though? Not much. A second redirect adds 10s of milliseconds to the request. I've never used hosting where I pay per GET request. If it is difficult to reconfigure it to a single redirect, I wouldn't worry about it.

Once you get into longer redirect chains, there can be problems. Pretty much everything should follow a chain of five or six redirects. Higher than that and some browsers will throw up errors and search engines bots may give up.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.