How long do browsers cache HTTP 301s?

前端 未结 15 2405
囚心锁ツ
囚心锁ツ 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:18

    Confirmed!! make the user submit a post request to the affected url and the cached redirect is forgotten.

    A quick win would be to enter this in the browser console if you can:

    fetch('example.com/affected/link', {method: 'post'}).then(() => {})

    Useful if you know the affected browser (especially during development).

    Alternatively, if you have access to the previous 301 redirect page, then you can add this script to the page and anytime it is visited, the cached 301 will be forgotten.

提交回复
热议问题