PHP controls cache after submitting a form

Source: Internet
Author: User
During the development process, forms often encounter errors and all information filled in when the page is returned is lost. to support page bounce, you can use either of the following methods. 1. use the header to set the Cache control header Cache-control. PHP code header (& amp; #39; Cache-control: p... "> <LINKhref =" http: // www. php1

 

During the development process, forms often encounter errors and all information filled in when the page is returned is lost. to support page bounce, you can use either of the following methods.

 

1. use the header to set the Cache control header Cache-control.

PHP code
  1. Header ('cache-control: private, must-revalidate'); // supports page jump back

2. use the session_cache_limiter method.

PHP code
  1. Session_cache_limiter ('private, must-revalidate'); // before session_start

The following describes the parameters of session_cache_limiter:

The meanings of several parameters in session_cache_limiter are as follows:
Nocache: of course, it is not cached (for example, the form information is cleared), but public variables can be cached.
Private: private cache (for example, the form information is retained but valid during the lifetime)
Private_no_cache: Private mode but not expired (form information is retained)
Publice: public (the form information is also retained)

Set the cache Expiration Time: Set the session_cache_expire function. the default value is 180 minutes.

Frequently encountered problems:

1. Session_cache_limiter ("private"); the form information is retained. However, if I modify the submitted information, the information displayed on the form page is still in the cache and cannot be automatically refreshed in time, if session_cache_limiter ("private") is not used, the form information cannot be retained.

Solution:

Before session_start, add

Session_cache_limiter ( "Private, Must-revalidate" );

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.