php back one page form content saving implementation method

  • 2020-05-17 04:56:05
  • OfStack

The php form steps back after submission, and the content of the form is cleared by default (using session_start),
The solution is to write after session_start() and before the character is printed
 
header("Cache-control: private"); 

The caching of web pages is controlled by "Cache-control" in the HTTP header. The common values are private, no-cache, max-age, must-revalidate, etc. The default value is private. Its function can be divided into the following situations according to different ways of re-browsing:
(1) open a new window
The values are private, no-cache, must-revalidate, and the server is revisited when a new window is opened.
If the max-age value is specified, the server will not be re-accessed for the duration of this value, for example:
Cache-control: max-age =5(means that the server will not be visited again within 5 seconds after this page is accessed)
(2) press enter in the address bar
If the value is private or must-revalidate, the server will only be accessed on the first access and will not be accessed again.
The value is no-cache, which is accessed every time.
The value is max-age, which is not accessed again until it expires.
(3) press the backward button
Values of private, must-revalidate, max-age will not be accessed again,
The value is no-cache, which is repeated each time
(4) press refresh and press button
No matter what the value is, it will be accessed repeatedly. Right
When the value of Cache-control is "no-cache", visiting this page will not leave a page backup in Internet's temporary article folder.
In addition, the cache is affected by specifying the "Expires" value. For example, if you specify the value of Expires to be 1 long past time, if you repeatedly press enter in the address bar when accessing the network, you will repeatedly access: Expires: Fri, 31 Dec 1999 16:00:00 GMT
For example, pages are not cached in IE
http response message header Settings:
CacheControl = no-cache
Pragma=no-cache
Expires = -1
Expires is a good thing. If the web page on the server changes frequently, set it to -1, which means it expires immediately. If a web page is updated at 1 a.m. each day, you can set Expires to 1 a.m. on day 2.
When the HTTP1.1 server specifies CacheControl = no-cache, the browser will not cache the page.
The old HTTP 1.0 server cannot use the Cache-Control header.
So for backward compatibility with the HTTP 1.0 server, IE provides special support for HTTP using the Pragma: no-cache heading.
If the client communicates with the server via a secure connection (https://) and the server returns the Pragma: no-cache header in the response,
Then Internet Explorer does not cache this response. Note: Pragma: no-cache prevents caching only when used in secure connections. If used in a non-secure page, it is handled the same way as Expires:-1, the page will be cached but marked as immediately expired.
Cache-Control header field description
Cache-Control specifies the caching mechanism that requests and responses follow. Set in the request message or response message
Cache-Control does not modify the cache processing in the other message processing. Cache instructions at request time include no-cache, no-store, max-age, max-stale, min-fresh, only-if-cached, The instructions in the response message include public, private, no-cache, no-store, no-transform, must-revalidate, proxy-revalidate, max-age. The instructions in each message have the following meanings:
Public indicates that the response can be cached by any cache.
Private indicates that the entire 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 message when a user, which is not valid for a request from another user.
no-cache indicates that the request or response message cannot be cached
no-store is used to prevent important information from being inadvertently published. Sending in a request message will take both the request and response messages out of cache.
max-age indicates that the client can receive a response with a lifetime of no more than a 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 a response message beyond the timeout period. If you specify the value of the max-stale message, the client can receive a response message that exceeds the specified value in the timeout.

Related articles: