Home  >  Article  >  Backend Development  >  Modifier did not find the program. Use PHP program to implement two methods to support page retreat.

Modifier did not find the program. Use PHP program to implement two methods to support page retreat.

PHPz
PHPzOriginal
2016-07-29 08:38:231131browse

What this article brings to you is about the two methods of using PHP programs to support page retreat when the program is not found by the modifier. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

First, use the Header method to set the message header Cache-control
QUOTE:
header('Cache-control: private, must-revalidate'); //Support page bounce
Second, use the session_cache_limiter method
QUOTE:
//Be sure to write it before the session_start method
Session_cache_limiter('private, must-revalidate');
Supplementary:
Cache-Control message header field description
Cache-Control specifies the caching mechanism followed by the request and response. Setting Cache-Control in a request message or response message does not modify the caching process during the processing of another message. The caching instructions during the request include no-cache, no-store, max-age, max-stale, min-fresh, only-if-cached, and the instructions in the response message include public, private, no-cache, no-store, no-transform, must-revalidate, proxy-revalidate, max-age. The meaning of the instructions in each message is as follows:
Public indicates that the response can be cached by any cache area.
 Private indicates that all or part of the response message for a single user cannot be processed by the shared cache. This allows the server to only describe a partial response from a user that is not valid for other users' requests.
No-cache indicates that the request or response message cannot be cached.
No-store is used to prevent important information from being released unintentionally. Sending it in the request message will cause both the request and response messages to use caching.
max-age indicates that the client can receive responses with a lifetime no greater than the specified time (in seconds).
Min-fresh indicates that the client can receive responses with a response time less than the current time plus the specified time.
max-stale indicates that the client can receive response messages beyond the timeout period. If you specify a value for max-stale messages, the client can receive response messages that exceed the specified value of the timeout period.
About form refresh
Q: Why is the information in all fields cleared after I click the browser's back button?
A: This is because you used the session_start function in your form submission page. This function will force the current page to not be cached. The solution is to add header("Cache-control: private") after your Session_start function; Note that your PHP program cannot have any output before this line.
Supplement: There is also a session-based solution, add
QUOTE before session_start:
session_cache_limiter('nocache'); // Clear the form
session_cache_limiter('private'); //Do not clear the form, only while the session is in effect
session_cache_limiter('public'); //Do not clear the form, just like not using session
You can add session_cache_limiter("private,max-age=10800"); before session_start();
               

The above introduces the two methods of using PHP programs to support page backing if the program is not found by the modifier, including the content of the program that is not found by the modifier. I hope it will be helpful to friends who are interested in PHP tutorials.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn