Ways to keep pages from being cached

Source: Internet
Author: User

Sometimes in order to implement some functions (such as refreshing data in real time), the browser needs to get the data from the server instead of using the cache.


HTTP headers "Expires" and "Cache-control" provide a mechanism to control caching on the browser and proxy servers

Expires tells the browser when its cached page expires and can be 0

Cache-control notifies the browser not to cache any pages

Two headers are defined in RFC7234


For HTML pages, use the

<meta http-equiv= "Pragma" content= "No-cache" ><meta http-equiv= "Cache-control" content= "No-cache, Must-revalidate "><meta http-equiv=" expires "content=" 0 ">

Control


For a JSP or servlet, use the

Response.setheader ("Cache-control", "No-store"); Response.setheader ("Pragrma", "No-cache"); Response.setdateheader ("Expires", 0);

Control

Ways to keep pages from being cached

Related Article

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.