[thelist] What is the Best Practice for Single Page Redirects?

Aredridel aredridel at nbtsc.org
Thu Jul 10 14:12:05 CDT 2003


On Thu, 2003-07-10 at 12:37, Lena Marianne Arvola wrote:
> Which of these methods is better for doing a single page redirect... 
> 
> Placing the following VBScript before the DOCTYPE:
> <%@ language="VBScript" %><% response.redirect("/url/goes/here/") %>
> 
> or to use the following meta tag:
> <meta http-equiv="REFRESH" content="0;URL=url/goes/here/">

It depends, honestly.

The meta-refresh is good when you want the user to know they're being
redirected, and even more so for faking server push, refreshing
something that's very frequently updated. It should not be used with a
timeout of zero, because it makes using the back button on the browser
painful.

The redirect method is better for most other things: a
permanent-redirect code sent to a browser will allow, say, a browser, to
automatically update bookmarks, and a temporary redirect code is the
most seamless way to send a user to another address.

I'd say "best practice" is to use the HTTP protocol to it's full
advantage, and use kludges like a meta tag are best left alone.

By the way, the "proper" way to do a refresh is not with a meta tag, but
the actual HTTP header:

    HTTP/1.1 200 OK
    Refresh: 5;URL=/foo/bar
    ...

    Content goes here

Whereas a redirect should look like this:

   HTTP/1.1 302 Temporarily Moved
   Location: url-goes-here
   ....

   Content goes here

and for a permanent move (as in a page having been moved to a new server
or location)

   HTTP/1.1 301 Permanently Moved
   Location: url-goes-here
   ...

   Content here

And more specifically, if the page is no longer around, but there's a
relevant other page, try code 303.

Ari




More information about the thelist mailing list