Minimize Number of Redirects
For viewing all tips see here
Applicable To
All Browsers
How Improves Page Load Time
By optimizing number of network roundtrips
Prologue
Redirect triggers an additional HTTP request and introduces an extra round trip. In case of redirect, server sends back the response with status code 301 or 302 i.e. ‘Moved Permanently’ or ‘Moved Temporarily’. Sometimes it is necessary for application to issue redirects, like to indicate a new location of resource, to track clicks and impressions of referring pages etc.
Why
o To minimize roundtrips
o Many browsers don’t honor the spec and won’t cache either 301 or 302 responses.
How
o Don’t redirect from multiple domains in order to reserve name space and catch incorrect user inputs either due to misspelled or incorrect URL.
o Application should have a way to update reference of the resources whenever they change their location.
o Handle incorrect URL on the server end itself by configuring mapping from one URL to another
o Add automatically the required trailing slash at the end of directory names
o Record page views in an asynchronous ways by including Java Script snippet at the bottom of target page, that notifies a logging server when a user loads the page
Exceptions
None
Recommendations
o Refer one resource with a single URL only
o Prefer HTTP redirects than Java Script redirects because JS can add parse latency in the browser whereas 301 or 302 requests can be processed immediately, before the browser parses the HTML document
Comments
Post a Comment