6

I'm looking to put in a 301 redirect to an application for specific values of a query string parameter.

For Example:

  • http://www.example.com/page?id=1 → redirect to a new page
  • http://www.example.com/page?id=2 → render normal response

How do browsers cache the redirect?

Specifically, after visiting the first URL, will some browsers start performing a 301 redirect for the id=2, or are redirects based on the full URL?

unor
  • 92,415
  • 26
  • 211
  • 360
jkelley
  • 2,570
  • 3
  • 21
  • 24

1 Answers1

6

Browser will definitely cache the 301 redirect because it's a permanent redirect. Basically you're telling the browser never to look at the original URL and to automatically go to the second URL. Same thing happens for any search engines. If you ever plan to use that original URL again, make sure you use a temporary redirect.

Specifically, after visiting the first URL, will some browsers start performing a 301 redirect for the id=2, or are redirects based on the full URL?

No, the browser should see each URI in it's entirety, so page?id=1 is a different URL than Page1?Id=2 and the 301 redirect would only apply to the first url.

Keep in mind that the browser is doing the redirect and implementing its own rules based on its interpretation of the HTTP spec. If there are any bugs in the browser you could get unpredictable results, but the short answer is that they're different requests to different urls and each get their own HTTP status code therefore they can be treated as separate pages.

Dave Mroz
  • 1,509
  • 2
  • 14
  • 27