PHP adds HTTP headers to disallow browser caching

Source: Internet
Author: User

in PHP can easily use the following statement to implement prohibit page caching, but it is difficult to remember the special arrangement, convenient for everyone to use.   Core code:
Copy the Code code as follows:
header ("Expires:mon, 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 useful for some pages, such as: verification code, because each generation of verification code must be different, otherwise the verification code does not make any sense, this can be implemented with the above statement to prohibit caching.
Another example: "Every huitie once a beautiful picture", the page cache must be disabled, otherwise the same image is returned in the cache.
recently saw the League of Baidu Alliance-"How to let Netizens Love your website" (mainly to discuss how to improve the user experience) to associate with one point:
take the forum as an example, when the user logged in after the landing page, such as "management", "modify data", etc., when the user quit the forum, again back to the page,
There are still "management", "modify data" and so on (because the cache page is returned), although the cookie has been emptied, "management", "modify material" and so on has not worked,
but users still think that this is a valid page, so that others can also "manage", "modify the material" and so on, that the site is unsafe (although it is actually safe). It is useful to add the above code on a page that requires cookie verification, at least to eliminate the negative effects on the user's mind.

PHP adds HTTP headers to disallow browser caching

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.