On my website i have a list of items, each item has a link, the link has one parameter named "ID":

<a href="go?id=2">item</a>

When i generate the list i don't know the exact url to the item, for example it could be too expensive (lots of queries to all kind of resources) to figure out.

When to user clicks the link "go?id=2" the server figures out the exact url and sends the user to that url with a redirect code 301. This will always be the same url.

I was wondering if i'm using the correct http code for my case? Mainly because while doing research i discovered more redirect codes than the usual 301 and 302.

  • 1
    For SEO you should always link to the final URL rather than to a redirect. You should find a way to make URL generation less expensive. That usually involves creating a persistent memory URL cache or preloading the data for all URLs into memory when the application starts. Mar 12, 2019 at 12:53
  • If it too problematic even for those solutions, you should simplify your URLs. Having all the redirects is worse for SEO than having URLs like /content-2 Mar 12, 2019 at 12:56

1 Answer 1


To answer your specific query, if this needs to be a redirect, then a 301 (permanent) is the correct one. It is always a GET request and it is permanent. The client will likely cache the 301 redirect, so will not query your site the next time.

However, as @Stephen mentioned in comments, you should ideally link to the target URL if at all possible.

At least cache the result of id=2 so that you can use the actual URL when the list of items is next generated. Or pre-compute these in the background at some point?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.