为什么刷新浏览器图像响应状态是 200,而不是 304?

Why refresh browser the image Response Status is 200, not 304?

我写了一个简单的代码:

<?php


echo "<h1>1233422</h1>";

?>

<html>

<img src="screen.png"/>
</html>

html中有一张图片,但是当我刷新浏览器页面时,png图片是200。

理论上图片响应状态应该是304,为什么是200?


两次请求的响应头是:

HTTP/1.1 200 OK
Content-Type: image/png
server: PhpStorm 10.0.1
date: Fri, 07 Dec 2018 03:35:42 GMT
cache-control: private, must-revalidate
last-modified: Fri, 07 Dec 2018 03:34:56 GMT
content-length: 11437

第二个请求头:

GET /test03-hante/screen.png HTTP/1.1
Host: localhost:63342
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Referer: http://localhost:63342/test03-hante/index.php
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: wp-settings-time-1=1539853185; Webstorm-b87204fd=531be1b1-a109-47c6-97d9-4dd7b886ebde

你看,没有 If-Modified-SinceIf-Non-Match 参数,为什么?

在浏览器刷新中,HTTP 图像响应状态为“200(缓存)”,因为在刷新时图像是从浏览器缓存中加载的。

您可以从这个答案中了解更多信息: