I understand that most of the languages support server side redirects (asp.net: Response.Redirect, PHP: header( 'newpage' ) ; )
. You could also do a redirect with JavaScript (window.location.href="newLocationURL")
.
When would you choose one over the other ?
With respect to ASP.net/IIS7(app pool in Integrated mode,enable 32 bit apps=false), I noticed that even when the page has a 302 header, the whole page body is sent to the client side.
And I believe this is not the case with PHP, only headers are sent ? To quote Redirect on client side means following steps:Client-side -> Server-side -> Client-side -> Server-side -> Client-side.
Redirect on Server-Side means:Client-side -> Server-side -> Client-side (headers only)* -> Server-side -> Client-side.
Is there a W3C standard or server side redirect implementation differ from one web server technology to another ?
Edit: I am only concerned about Response.Redirect (in asp.net) and not server.transfer, at least for this discussion
The JavaScript example is actually not a redirect. There's no means of a 301/302 response. It is just a simple request which happens during a certain Javascript event long time after the page is arrived. If you do this during page load, then it would have more overhead than a real redirect and it would not work on JS-disabled browsers as well.
Redirects are to be initiated from the server side with a 301/302 response. All webapp languages/frameworks defaults to 302. You can usually make it 301 by adding one extra parameter or code line which instructs that. The benefit of 301 is by the way that the particular request won't be indexed (anymore) by the searchbots.