However, there is a situation that cannot be prevented:
After the user submits the form, click the back button of the browser to return to the form page. At this time, the browser will directly retrieve the page from the cache, so the token verification must be passable.
There are many ways to bypass this problem on the Internet. For example, the location. replace () method is used to replace the current history, but this still has flaws. In extreme cases, if a user switches between pages multiple times, the button may return to the previous form page several times.
The solution is to set Cache-Control: no-cache, no-store in the http header. However, I tried to add <meta http-equiv = "Cache-Control" content = "no-cache, no-store "> the output header (" Cache-control: no-cache, no-store ") in the Action is invalid.
Size: 25.42 K
Size: 345x195
Browsing: 2 times
Click Open new window browse full graph "height =" 195 "src =" http://files.jb51.net/upload/201108/20110808213814539.jpg "width =" 345 "border =" 0 ">
After searching for a long time, I found that the problem lies in the template rendering mechanism of ThinkPHP. Open ThinkPHP/Lib/Think/Core/View. class. php to check the 173rd rows.
header( "Cache-control: private" ); // Supports page bounce |
In order to support page bounce, the original TP forces a Cache-control: private header to be sent before each template is output, which is really helpful.
Comment out this line, delete the TP core cache, and try again. The HTTP response header is changed successfully.
Size: 30.6 K
Size: 502x191
Browsing: 3 times
Click Open new window browse full graph "height =" 191 "src =" http://files.jb51.net/upload/201108/20110808213816334.jpg "width =" 500 "border =" 0 ">