Hacker News new | ask | show | jobs
Tangled issues with permanent HTTP redirects (utcc.utoronto.ca)
11 points by pcr910303 1361 days ago
5 comments

There seems to be some FUD going on here. The solution to the OP problem is simply to use 301 redirects with Cache-Control headers to limit caching to some reasonably short duration.

It is true that browsers will cache 301 redirects eternally, but only if the server does not supply cache directives to indicate otherwise. For this reason, it is always advisable to include some cache directives in 301 redirect responses, like `Cache-Control: max-age=86400`. I'm surprised that this isn't more universally acknowledged as an important practice.

As far as search engines, there will not be a problem if a URL that used to return a 301 now returns a 200. The web changes, and search engines know that very well.

Add: There also seems to be a lot of confusion about the meaning of permanent. Permanent should not be taken to mean eternal. If I move to a new house, I consider that a permanent move, because I no longer live at the old address. But it would be unreasonable to assume that I will never move again. I might even move back to the original house! Such moves are like permanent redirects; I might have my mail forwarded, but it is not an indelible, eternal change. Temporary redirects (302, 303, 307) are more like leaving a sticky note on the door while you're out running an errand; you have not permanently relocated.

In this case, permanent == indefinite, and temporary == ephemeral is a good way to think of it.
Those are good words to use. That's how people should think of these redirects and use them, as long as you are careful to use explicit cache directives.
Thank you for taking the time to post such an insightful message.
Permanent redirects are often times just premature optimization. Keep them temporary, preferably 307 to avoid odd browser behaviour with method change.
Maybe not a good practice but I've recently discovered that caches respect the Cache-Control header even for 301s. This can make 301s not really permanent and give more control on the caching behavior
This short essay is good philosophy, but doesn't seem very connected with reality. No, search engines and browsers don't permanently cache permanent redirects. Yes, you should probably use unique usernames instead of reusing them. The second fully mitigates the first, for this particular situation.
From some quick googling, everything I can find claims that browsers permanently cache permanent redirects. The MDN also says that a 301 causes search engines to update the link in their index.

Don't just make claims, support them. Link to anything which demonstrates that permanent redirects aren't cached permanently.

If it's not permanent then just keep it temporary... I don't see the problem here
The problem is that perfectly distinguishing permanent and temporary redirects requires infallible knowledge of the future, which is not possible.
"permanent" redirects are practically never treated as permanent, though... They are just treated as more permanent
Part of the problem is the belief that a 301 is the best option for SEO because it passes 'link juice'.

Evidence for this being true will always be some random blog post from a self proclaimed expert.

My default option is always a 302 for the simple fact that it isn't going to be cached and can be easily changed with no ill effects. I've yet to notice any disadvantage from an seo point of view.

What is "link juice here?
Link juice is the term used in the SEO world to refer to the value or equity passed from one page or site to another. This value is passed through hyperlinks. Search engines see links as votes by other websites that your page is valuable and worth promoting.

https://www.woorank.com/en/edu/seo-guides/link-juice