PHP code for disabling page cache _ PHP Tutorial

Source: Internet
Author: User
PHP disables page cache code. Core code: Copy the code as follows: header (Expires: Mon, 26Jul199705: 00: 00GMT); header (Last-Modified :. gmdate (D, dMYH: I: s ). GMT); header (Cache-Control: no-cache core code:

The code is as follows:


Header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT ");
Header ("Last-Modified:". gmdate ("D, d m y h: I: s"). "GMT ");
Header ("Cache-Control: no-cache, must-revalidate ");
Header ("Pramga: no-cache ");


This is very useful for some pages. for example, the verification code must be different each time the verification code is generated. Otherwise, the verification code has no meaning, so you can use the preceding statement to disable caching.
For another example, "change a beautiful image every time you paste it back", the page cache must be disabled; otherwise, the same image will be returned in the cache.
Recently, I 've seen the alliance's blog on Baidu Union-"how to make netizens fall in love with your website" (mainly discussing how to improve user experience) come to a point:
Take the forum as an example. after a user logs on, the displayed page is "manage" and "modify information". after the user exits the forum, the user returns to the previous page again,
There are still "management" and "modify data" (because the cache page is returned). Although the cookie has been cleared at this time, "management" and "modify data" have no effect,
However, users still think that this is a valid page, so that others can also "manage", "modify information" and so on, and think that the website is not secure (although it is actually safe ). At this time, the above code is very useful on the page that requires cookie verification, at least to eliminate the adverse effects on user psychology.

The authorization code is as follows: header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header ("Last-Modified :". gmdate ("D, d m y h: I: s "). "GMT"); header ("Cache-Control: no-cache...

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.