How does php static file return 304? Prompt Page not updated

Source: Internet
Author: User
  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

Description: This function can be called before a static file (slice) is output.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.