Cache-control settings in php are invalid

Source: Internet
Author: User
This is the request information. we can see that cache-control has been set successfully. however, a new request is required from the server. the status here should be 200, but the size should be fromcache.

This is the request information. we can see that cache-control has been set successfully.

However, a new request is required from the server.

The status here should be 200, but the size should be from cache.

Reply content:

This is the request information. we can see that cache-control has been set successfully.

However, a new request is required from the server.

The status here should be 200, but the size should be from cache.

See the following example.


   time() ){     header("HTTP/1.1 304");     exit; } header("Last-Modified: ".gmdate("D, d M Y H:i:s", time() )." GMT");  echo time(); ?>

Open it in a browser. we can see that the status code 200 is returned for the first time, and the printing time is the latest time. Then we opened it for the second time. we can see that the status code is 304, and the time is the same as the previous time, indicating that we are using the cache. We delete the last_modified.php file, and then open the page for the third time. the browser returns error 404. it can be seen that although Last-Modified uses the cache, each time you open the page, you still need to initiate an http request to the server, the browser determines whether the browser content expires based on the user's $ _ SERVER ['http _ IF_MODIFIED_SINCE ']. if the browser content does not expire, the browser returns the 304 status and the browser content is read from the cache.

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.