Is it OK to HTTP redirect images?

前端 未结 3 771
眼角桃花
眼角桃花 2020-12-02 18:20

Is it OK to return a 301 / 302 / 303 code when returning an image resource? I have done this in the past and it seems to work. Is it good practice and is it compatible with

3条回答
  •  清歌不尽
    2020-12-02 19:14

    Yes, it works.

    About being good practice, what are the alternatives? Returning an error response (404)? Not very helpful. Returning the image that the redirected resource would return? Probably not possible, otherwise you would not redirect. Fixing the img tags with the new URL? Sure, where possible, but maybe you want the browser to go thorough the redirection (a counter maybe).

提交回复
热议问题