Why do browsers inefficiently make 2 requests here?

前端 未结 9 2201
-上瘾入骨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:36

    This may be a shot in the dark, but here's what I think is happening.

    According to, http://api.jquery.com/jQuery.get/

    dataType
      Type: String
      The type of data expected from the server. 
      Default: Intelligent Guess (xml, json, script, or html).
    

    Gives you 4 possible return types. There is no datatype of image/gif being returned. Thus, the browser doesn't test it's cache for the src document as it is being delivered a a different mime type.

提交回复
热议问题