Detailed explanation of two methods to let PHP support page rollback

怪我咯
Release: 2023-03-13 09:54:01
Original
1212 people have browsed it

During the development process, often due to form errors, the information filled in when returning to the page is missing. In order to support page bounce, this can be achieved through two methods.
First, use the Header method to set the message header Cache-control

header('Cache-control: private, must-revalidate'); / /Support page bounce

Second, use the session_cache_limiter method

//Be sure to write it before the session_start method
session_cache_limiter('private, must-revalidate ');

PS: Cache-Control message header field description
Cache-Control specifies the caching mechanism that requests and responses follow. Setting Cache-Control in a request message or response message does not modify the cache processing process in another message processing process. 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 a response 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.

The above is the detailed content of Detailed explanation of two methods to let PHP support page rollback. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!