火狐弃用http,转而大力推广https的动作一石激起千层浪,非常多没有安装安全证书的站点使用新版火狐浏览器已经打不开了。
之前我们站点仅仅有涉及须要加密的部分连接为https协议。眼下看来不得不将整个站点的连接均加装https。原本执行正常的功能就这样出现了问题。具体情况是,产品列表页面使用ajax载入产品的时候不能再像从前那样缓存之前载入好的数据了。造成这样的情况的原因主要有两点,第一点是在后台设置的过滤器强制每一个页面不缓存内容。第二个原因便是由于整个站点都进行了安全加密,使得浏览器本身不会再进行页面缓存。解决问题的方法是在须要缓存数据的页面设置强制缓存,例如以下:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <% String path = request.getContextPath(); int nMinutes = 60 * 24 * 7; Date d = new Date(); String modDate = d.toGMTString(); String expDate = null; expDate = (new Date(d.getTime() + nMinutes * 60000)).toGMTString(); response.setHeader("Last-Modified", modDate); response.setHeader("Expires", expDate); response.setHeader("Pragma","public"); response.setHeader("Cache-Control","public"); %> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <link href="<%=path%>/resources/weixin/css/style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="<%=path%>/resources/weixin/js/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="<%=path%>/resources/weixin/js/progressbar.js"></script> <script type="text/javascript" src="<%=path%>/resources/weixin/js/common.js"></script> <script type="text/javascript" src="<%=path%>/resources/weixin/js/account.js"></script> <script type="text/javascript" src="<%=path%>/resources/js/common.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#investpage").addClass("current"); if(isWeiXin()){ $("#page").val("1"); } addMoreProducts(); }); </script> <title>普惠理財-产品列表</title> </head> <body> <header id="header"> <h3>产品列表</h3> </header> <div id="container"> <form id="centerForm" name="centerForm" method="post" action=""> <input type="hidden" id="page" name="page" value="1" /> </form> <div id="proList" class="pro_list"> </div> <div id="addTag " class="addTag"> <a href="javascript:void(0)" onclick="addMoreProducts()"> <span id="loading" class="icon"></span><span id="promtText">载入中...</span> </a> </div> </div> <footer id="footer"> <jsp:include page="../footer.jsp" /> </footer> </body> </html>
尤其要注意Cache-Control的值和Pragma的值均为”public“。
时间: 2024-10-10 10:45:30