How long do browsers cache HTTP 301s?

前端 未结 15 2279
囚心锁ツ
囚心锁ツ 2020-11-22 14:43

I am debugging a problem with a HTTP 301 Permanent Redirect. After a quick test, it seems that Safari clears its cache of 301s when it is restarted, but Firefox does not.

15条回答
  •  北海茫月
    2020-11-22 15:20

    as answer of @thomasrutter

    If you previously issued a 301 redirect but want to un-do that

    If people still have the cached 301 redirect in their browser they will continue to be taken to the target page regardless of whether the source page still has the redirect in place. Your options for fixing this include:

    The simplest and best solution is to issue another 301 redirect back again.

    The browser will realise it is being directed back to what it previously thought was a decommissioned URL, and this should cause it re-fetch that URL again to confirm that the old redirect isn't still there.

    If you don't have control over the site where the previous redirect target went to, then you are outta luck. Try and beg the site owner to redirect back to you.

    In fact, this means:

    1. a.com 301 to b.com

    2. delete a.com 's 301

    3. add b.com 301 to a.com

    Then it works.

提交回复
热议问题