Java servlet how to disable caching of page

后端 未结 2 883
一整个雨季
一整个雨季 2020-12-06 11:00

How to disable caching ?

What headers should doGet set?

Could you provide a code snippet?

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 11:26

    This will set caching to disabled on the response:

    // Set standard HTTP/1.1 no-cache headers.
    response.setHeader("Cache-Control", "private, no-store, no-cache, must-revalidate");
    
    // Set standard HTTP/1.0 no-cache header.
    response.setHeader("Pragma", "no-cache");
    

提交回复
热议问题