Php header is not output after execution
$ TestStr = "aaa ";
$ TestStr = "ccccccccc ";
Header ("HTTP/1.1 304 Not Modified ");
Echo $ testStr;
?>
Why is my code not output?
Reply to discussion (solution)
You don't know what 304 means?
304 indicates that the body is the same as the "last", and only the header is sent without the body. it is usually used in the response to the client refresh (that is, it was sent once before a short time)
304 can reduce a lot of server traffic, but it is not easy to accurately determine the last time in the program and grasp the time period.
For dynamic page Cache Acceleration, first add the Last Modified definition to the HTTP Header of Response, and then return 200 or 304 according to the If Modified Since in the Request and the update time of the requested content. Although a database query has been performed when 304 is returned, more database queries can be avoided, and no page content is returned, instead of an HTTP Header, this greatly reduces bandwidth consumption and improves user experience.
Thank you for your answers. I am working on etag. I have answered all the answers. The problem has been solved.