http-status-code-304

How “304 Not Modified” works?

血红的双手。 提交于 2019-11-26 07:57:20
问题 How \"304 Not Modified\" is generated? How does a browser determine whether the response to a http request is 304? Is it set by the browser or sent from the server? If sent by server, how does server know the data available in cache, also how does it set 304 to an image? My guess, if generated by browser function is_modified() { return get_data_from_cache() === get_data_from_url(); }; function get_data_from_cache() { return some_hash_or_xxx_function(cache_data); } function get_data_from_url()

How to check if jQuery.ajax() request header Status is “304 Not Modified”?

对着背影说爱祢 提交于 2019-11-26 06:01:43
问题 How to check if jQuery.ajax() request header Status is \"304 Not Modified\"? jqXHR.status usually returns 200 , even when requested header is \"304 Not Modified\". ifModified:true does not help a lot because it breaks XHR data request. 回答1: Without handling cache headers manually, it is not possible. Normally, 304 responses are not made available through the XHR API: For 304 Not Modified responses that are a result of a user agent generated conditional request the user agent must act as if