cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Upayavira">
Subject Permanent Redirects
Date Mon, 23 Jun 2003 07:10:16 GMT
I've worked out how I'd like to implement permanent redirects. I'd appreciate 
comments as to whether this approach is okay. I would rather have comments 
before just doing it...

Add to o.a.c.environment:

public interface PermanentRedirector {

    void redirectPermanently(boolean sessionmode, String url) throws IOException, 

Make HttpEnvironment and HttpResponse implement this interface. 
HttpEnvironment.redirectPermanently() calls HttpResponse.redirectPermanently(). 
HttpResponse.redirectPermanently() sets the status to 
SC_MOVED_PERMANENTLY and sets a 'location' header in the response.

Then the RedirectToNodeBuilder needs to be extended to handle a 'permanent' 
attribute for the <map:redirect-to> node.

Finally, in RedirectToURINode.invoke(), test to see if both the permanent attribute 
has been set, and the current Redirector implements PermanentRedirector, and if 
so, call redirectPermanently() instead of just redirect().

I think that does it. Am I breaking any contracts, or extending the sitemap 
language when I shouldn't be?

So, why permanent redirects?

A 301 (Permanent Redirect) informs the user agent that a URL has changed
permanently, and to use the new one form there onwards. Caching of the new
page is as usual.

A 302 (Temporary Redirect) informs the user agent and any proxy servers in
the loop that a URL has changed temporarily, and may change again. The
user agent and any proxy servers will _not_ cache the new page. So 302's put an 
extra load on the server and all elements downstream of it as the pages are not 

And that's why 301s are better if the page has moved permanently, but 302s
are fine for a temporary change.

Thanks, Upayavira

View raw message