Live data from Hacker News

301 redirects: a dangerous one way street (2012)

jacquesmattheij.com

1–10 of 92 posts

Re: 301 redirects: a dangerous one way street (2012)

#2
That's what permanent means. "Adjective permanent Without end, eternal. Lasting for an indefinitely long time. "

Also, "This response is cacheable unless indicated otherwise," says RFC 2616.

Working as designed, IMNSHO. Perhaps not working as intended, but alas, that's a case of ¬RTFM.

Re: 301 redirects: a dangerous one way street (2012)

#3
The problem with 301 without cache headers is that some browsers cache this forever due to some interpretation what 'permanent' means.

You often can't use 302 because all your external links no longer work SEO magic for you with a 302. Google only transfers link juice with 301 [1].

If you make a mistake and misconfigure your server, you're toast.

If a disgruntled employee 301 redirects your domain, you're toast.

If a service provider misconfigures your domain, you're toast.

If a hacker (from a competitor) 301 redirects your domain, you're toast.

If you buy a domain that had a 301 on it, it's worthless.

If you buy a domain that had 301s on it that point to phishing sites, you're in trouble.

I always add cache headers to 301 redirects I use to at least prevent me from shooting myself with an arrow in my knee.

UPDATE: [1] Google seems to have changed this recently. It also no longer considers http/https different pages as it did in the past with the same content https://www.searchenginejournal.com/google-confirms-no-loss-...

Re: 301 redirects: a dangerous one way street (2012)

#5
"There are only two hard things in Computer Science..."

I guess some people think the purpose of 301 is more like that of 410: update references so you don't try to go there again. The difference is that with 301 you additionally instruct the client to not even attempt to go there again in the future.

But the article does raise an interesting point: if I own somedomain.example and set it up with a 301 redirect to myotherdomain.example and enough people visit it that most people will have cached the redirect, doesn't that basically mean I now own it for perpetuity (or until enough people have cleared their cache) even if I don't renew the domain and new requests to the domain are no longer served (by the same IP)?

Or do browsers have some kind of protections against this, at least based on DNS? It's a bit too convoluted for a proper DOS attack (because you need to own the domain long enough and make it popular enough to poison everyone's caches) but a naive implementation seems like it would effectively render domains unusable if someone set up a 301 on them at some point in the past.

Re: 301 redirects: a dangerous one way street (2012)

#6

HSTS is similarly one-way, but it's not indefinite, I think.

It's not indefinite because you need to specify a duration. However nothing stops you from setting an extremely long duration and in fact most tutorials seem to advise doing so for safety reasons.

Re: 301 redirects: a dangerous one way street (2012)

#7
I took over a domain which had previously 301-redirected HTTP:// to HTTPS://. It caused us no end of trouble getting the alpha site online -- obviously we set up SSL but we didn't realise it was the _first thing we'd have to do_.

It also caused half a day of confusion to understand why some of our web browsers were still failing to connect and others could see the alpha site (because they'd never visited the previous 301 site at that address).

Re: 301 redirects: a dangerous one way street (2012)

#9

The problem with 301 without cache headers is that some browsers cache this forever due to some interpretation what 'permanent' means. You often can't use 302 because all your external links no longer work SEO magic for you with a 302. Google only transfers link juice with 301 [1]. If you make a mistake and misconfigure your server, you're toast. If a disgruntled employee 301 redirects your domain, you're toast. If a…

It would be great if there were a service that allowed you to search non-cached controlled 301s a crawler had encountered.

Re: 301 redirects: a dangerous one way street (2012)

#10
post #8

> You can improve a bit on this by sending along a bunch of cache control headers to at least limit the damage. It would have been useful to include those headers in the blog post.

Something like this says "keep this cached for 100 days":

Last-Modified: Fri, 19 Feb 2016 12:54:49 +0100

Expires: Sun, 29 May 2016 12:54:49 +0200

Cache-Control: max-age=8640000, must-revalidate

See also: https://www.mnot.net/cache_docs/#CONTROL

Post reply on HN