Add an Expires or a Cache-Control header in JSP

前端 未结 4 860
别跟我提以往
别跟我提以往 2020-11-30 22:08

How do you add an Expires or a Cache-Control header in JSP? I want to add a far-future expiration date in an include page for my static components

4条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 22:25

    <%
        response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
        response.setHeader("Pragma", "no-cache"); //HTTP 1.0
        response.setDateHeader("Expires", 0); //prevents caching at the proxy server
    %>
    

提交回复
热议问题