Search code examples
htmlhttpphpstorm

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


I write a simple code:

<?php


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

?>

<html>

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

there is an image in the html, but when I refresh the browser page the png image is 200.

theoretically the image response status should be 304, why there is 200?

200


Two times request's Response Header are:

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

the second request Headers:

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

you see, there is no If-Modified-Since and If-Non-Match params, why?


Solution

  • In browser refresh, HTTP image response status is "200 (cache)" because in refresh the image loaded from your browser cache.

    You can learn more from this answer: https://stackoverflow.com/a/1665097/6678086