一、页面
在HTML页面中设置<meta http-equiv="Expires" content="Thu, 16 Dec 2010 23:00:00 GMT" /> (必须是GMT格式,如果是其它格式或是0,则表示立即过期)后,可以缓存页面,但 <meta http-equiv="Cache-Control" content="max-age=72000" />经测试在IE6-8中都不生效
二、HttpServletResponse
HttpServletResponse res = (HttpServletResponse)response;
设置 res.setHeader("Expires", "Thu, 16 Dec 2010 23:00:00 GMT"); 或
res.setHeader("Cache-Control", "max-age=72000"); 都生效
三、java中生成GMT格式串
java.util.Date date = new java.util.Date();
DateFormat df = new SimpleDateFormat("EEE, d-MMM-yyyy HH:mm:ss z", Locale.ENGLISH);
df.setTimeZone(TimeZone.getTimeZone("GMT")); // modify Time Zone.
System.out.println("GMT Time: " + df.format(date));