Why do browsers inefficiently make 2 requests here?

前端 未结 9 2167
-上瘾入骨i
-上瘾入骨i 2021-02-13 14:48

I noticed something odd regarding ajax and image loading. Suppose you have an image on the page, and ajax requests the same image - one would guess that ajax requests would hit

9条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-13 15:34

    Your fiddle tries to load a resource from another domain via ajax: cross domain request

    I think I created a better example. Here is the code:

    smiley
    

    You can test the page here.

    According to Firebug and the chrome network panel the image is returned with the status code 200 and the image for the ajax request is coming from the cache:

    Firefox: Firebug

    Chrome: chrome network panel

    So I cannot find any unexpected behavior.

提交回复
热议问题