When to use Location and Refresh to do redirection.
header( "Location: www.dominio.com" , TRUE , 302 ) header( "Refresh:5; url=www.dominio.com" , TRUE , 302 )
Both options produce the same result: redirect . The difference is that using Location the redirection is instantaneous, while Refresh you can set a delay for the redirection.
I am wanting to understand the differences between the two cases when opting for one or the other. Since Refresh has the advantage of picking time, I don't see any point in Location .
You can set status 3xx in both cases. The status-code is the one who reports cases of redirection, so Location and Refresh are just a means to an objective – are they indifferent?
Both functions serve to redirect/refresh a page, however they have different ways of working.
Location , the browser doesn't have to download the entire content of the page before redirecting. This way there will be no problems using your browser's back button as the function is done server-side.
Refresh function you will be sending a request to the browser (client-side) to refresh the page. That is, the browser will first download the page and then the time set in the meta tag will redirect the page. Also, if the user clicks "Back" in the browser it will not work as it should, as it will return to the page they just left and will be redirected again.
- server side
- Does not download site before redirect
- client side
- Can set time to send to next page
- It can interfere with the proper functioning of the browser's back button
- Download website content before redirecting
For more information: http://www.w3.org/QA/Tips/reback