How do php static files return 304? Prompt page has not been updated

WBOY
Release: 2016-07-25 08:52:18
Original
1037 people have browsed it
  1. private function _addEtag($file) {
  2. $last_modified_time = filemtime($file);
  3. $etag = md5_file($file);
  4. // always send headers
  5. header("Last-Modified: ".gmdate ("D, d M Y H:i:s", $last_modified_time)." GMT");
  6. header("Etag: $etag");
  7. // exit if not modified
  8. if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE ']) == $last_modified_time ||
  9. @trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
  10. header("HTTP/1.1 304 Not Modified");
  11. exit;
  12. }
  13. }
Copy code

Instructions: This function can be called before static files (such as pictures) are output.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!