Session_cache_limiter (private, must-revalidate)

Source: Internet
Author: User
    • Session_cache_limiter (private, must-revalidate)

      Table 1:

      Specify the buffer control method used by the session page:
      When session_cache_limiter ('private') is used to make the form history. Go (-1), The entered content is not lost! To avoid page failure warnings!

      Table 2:

      This session has the same effect as the header ('cache-control: private, must_revalidate ').

However, it is worth noting that the session_cache_limiter () method is useful only before the session_start () method;

Detailed page Jump explanation and session_cache_limiter () usage explanation

Now we can use ajax to verify the form and prompt users at any time. However, when the user does not pay attention to the Ajax friendly prompt, the user submits an incorrect form and jumps back to the original page, all information entered is lost. To support page bounce, you can do the following:

    • 1. Use the session_cache_limiter method:


    1. Session_cache_limiter ('Private, must-revalidate ');
Session_cache_limiter ('Private, must-revalidate ');

However, it is worth noting that the session_cache_limiter () method is useful only before the session_start () method;

    • 2. Use the header to set the Cache control method:

During the development process, the information filled in when the page is returned due to a form error is often lost. To support page Jump, you can use two methods.

First, use the header method to set the message header cache-control


Header ('cache-control: private, must-revalidate'); // supports page Jump back

Second, use the session_cache_limiter method.


// Note that it should be written before the session_start method.

Session_cache_limiter ('Private, must-revalidate ');


Cache-Control Message Header domain description

Cache-control specifies the cache mechanism that requests and responses follow. Setting cache-control in a 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 instructions in each message are 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 the request or response message cannot be cached.

No-store is used to prevent the 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 response messages that exceed the timeout period.

About form refresh

Q: Why are all fields cleared after I click the back button of the browser?

A: This is because you have used the session_start function on your form submission page. This function forces the current page not to be cached. Solution: add the header (double quotation mark cache-control: Private double quotation mark) after your session_start function. Note that your phpProgramNo output is allowed.

Supplement: there is also a session-based solution, which is added before session_start.


Session_cache_limiter ('nocache'); // clear the form

Session_cache_limiter ('private'); // do not clear the form, only during the effective period of the session

Session_cache_limiter ('public'); // do not clear the form, as if the session is not used

You can add session_cache_limiter ('Private, Max-age = 10800 ') before session_start ');

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: 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.