PageSpeed : Minimise redirects


Minimising HTTP redirects from one URL to another cuts out additional RTTs and wait time for users.

What is an HTTP Redirect?

Definition For HTTP Redirection from Wikipedia

URL redirection, also called URL forwarding, is a World Wide Web technique for making a web page available under more than one URL address. When a web browser attempts to open a URL that has been redirected, a page with a different URL is opened. For example, is redirected to Similarly, Domain redirection or domain forwarding is when all pages in a URL domain are redirected to a different domain, as when and are automatically redirected to URL redirection can be used for URL shortening, to prevent broken links when web pages are moved, to allow multiple domain names belonging to the same owner to refer to a single web site, to guide navigation into and out of a website, for privacy protection, and for less innocuous purposes such as phishing attacks.

Sometimes its necessary to issue http redirects. like in below cases

  • To indicate new address of a resource that has moved from it's previous location.
  • To track  clicks and impressions and log referring urls.
  • To catch misspelled urls, and redirect to vanity url's or to user friendly url's.
  • To issue secure browsing . http to https.
  • To add  different country-code top-level domains as per the country of visitor. ".com" to ".in"  or to ".uk"
  • To add a trailing slash to URL directory names to make their contents accessible to the browser.

Solutions / Recommendations

Eliminate unnecessary redirects

Avoid adding urls that are known to redirected to another url. instead add the absolute url where the redirection ends.

Use server rewrites for user-typed URLs.

many servers supports URL rewriting mechanism. make use of rewriting to serve correct urls or mistyped urls.

Prefer HTTP over JavaScript or meta redirects.

There are several ways to redirect a page to another.

Using JavaScript.

We can redirect a page to another one using window.location object.

Using Meta tag


Using Server Side mechanism

This is recommended to follow this way to redirect your page to another.
Because in JavaScript and meta ways, browser will have to parse the document in client browser to redirect .
but if it is done server side, client will not have to download the document. thus it reduces latency and page loads faster.


Post a Comment