PHP cache controller details

Source: Internet
Author: User

InHeader ("Cache-control: private"); the webpage Cache is controlled by the PHP Cache controller in the HTTP message header, common values include private, no-cache, max-age, and must-revalidate. The default value is private. The function of browser review is divided into the following situations:

(1) open a new window

If the values are private, no-cache, and must-revalidate, the server will be accessed again when a new window is opened.

If the max-age value is specified, the server will not be accessed again within the time range. For example:
PHP cache Controller: max-age = 5 (indicating that the server will not be accessed again within 5 seconds after the webpage is accessed)

(2) Press enter in the address bar.

If the value is private or must-revalidate, the server will be accessed only during the first access and will not be accessed in the future.
The value is no-cache.
If the value is max-age, the access will not be repeated before expiration.

(3) Back and press the button

If the values are private, must-revalidate, and max-age, no re-access is performed,
If the value is no-cache, access is repeated each time.

(4) press the refresh button

When the PHP cache controller value is "no-cache" repeatedly accessed for whatever value, accessing this page will not leave page backup in the temporary article folder on the Internet. In addition, specifying the "Expires" value also affects the cache.

For example, if you specify the Expires value as a time that has passed, if you repeatedly press enter in the address bar when accessing this network, the access will be repeated every time: Expires: Fri, 31 Dec 1999 16:00:00 GMT for example: Prohibit page caching in IE http Response Message Header settings: CacheControl = no-cache
Pragma = no-cache

Expires =-1Expires is a good concept. If the webpage on the server changes frequently, set it to-1, indicating that it will expire immediately. If a webpage is updated at every day, you can set Expires to the next day. When CacheControl = no-cache is specified on the HTTP1.1 server, the browser does not cache the webpage. The old-style HTTP 1.0 server cannot use the PHP cache controller title.

To be backward compatible with HTTP 1.0 servers, IE uses the Pragma: no-cache title to provide special support for HTTP.
If the client communicates with the server through a secure connection (https: //) and the server returns the Pragma: no-cache title in the response, Internet Explorer does not cache the response. Note: Pragma: no-cache prevents caching only when used in secure connections. If used on a non-secure page, the processing method is the same as Expires:-1, this page will be cached but marked as expired immediately.

Message Header field of the PHP cache Controller

Cache-Control specifies the Cache mechanism that requests and responses follow. Setting the PHP cache controller in the request message or response message does not modify the cache processing process of another message. The cache commands in the request include no-cache, no-store, max-age, max-stale, min-fresh, only-if-cached, commands in the Response Message include public, private, no-cache, no-store, no-transform, must-revalidate, proxy-revalidate, and max-age.

The meaning of commands in each message is as follows: Public indicates that the response can be cached in any cache area. Private indicates that the whole or part of the response message of a single user cannot be processed by the shared cache. This allows the server to only describe part of the user's response message, which is invalid for requests of other users. No-cache indicates that no-store cannot be cached for request or response messages to prevent unintentional release of important information.

Sending a request message does not cache the request and response messages. Max-age indicates that the client can receive responses with a lifetime not greater than the specified time (in seconds. Min-fresh indicates that the client can receive a response whose response time is earlier than the current time plus the specified time. Max-stale indicates that the client can receive response messages beyond the timeout period. If the value of the max-stale message is specified, the client can receive the response message beyond the timeout period.


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.