The function of the header () is to send an original HTTP header [HTTP header] to the client.
The header is a string sent by the server to the browser before the HTML data is transmitted to the HTTP, in the header
There is an empty line separating the HTML file. Let me share with you a PHP technology that uses the header to set the browser cache.
<?php //define a reasonable cache time. The reasonable value of the page itself, the number of visitors and the page update frequency, here is 3,600 seconds (1 hours). $cache _time = *; $modified _time = @$_server[' http_if_modified_since '); if (Strtotime ($modified _time) + $cache _time > Time ()) { header ("http/1.1 304"); Exit; } Sends the last-modified header, setting the last updated date for the document. header ("last-modified:". Gmdate ("D, D M Y h:i:s", Time ()). " GMT "); Send the Expires header, set the current cached document expiration time, GMT format, we are using the gmt+8 time zone header ("Expires:". Gmdate ("D, D M Y h:i:s", Times () + $cache _time) ." GMT "); Send Cache_control header, set xx seconds after the document obsolete, can replace expires, if at the same time, max-age priority. header ("cache-control:max-age= $cache _time"); echo time (); ? >
about using the header () function. And you have a lot of knowledge, the next small series will continue to share with you about the usage of the PHP header function and its considerations, and so on.