TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Tangled issues with permanent HTTP redirects

11 pointsby pcr910303over 2 years ago

5 comments

ademarreover 2 years ago
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.<p>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 <i>always</i> advisable to include some cache directives in 301 redirect responses, like `Cache-Control: max-age=86400`. I&#x27;m surprised that this isn&#x27;t more universally acknowledged as an important practice.<p>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.<p>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&#x27;re out running an errand; you have not permanently relocated.
评论 #32957696 未加载
评论 #32950127 未加载
silverwindover 2 years ago
Permanent redirects are often times just premature optimization. Keep them temporary, preferably 307 to avoid odd browser behaviour with method change.
alserioover 2 years ago
Maybe not a good practice but I&#x27;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
wumpusover 2 years ago
This short essay is good philosophy, but doesn&#x27;t seem very connected with reality. No, search engines and browsers don&#x27;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.
评论 #32949252 未加载
weird-eye-issueover 2 years ago
If it&#x27;s not permanent then just keep it temporary... I don&#x27;t see the problem here
评论 #32948606 未加载
评论 #32948813 未加载