cacheSeconds的故事

	<bean name="/helloWithOutMode" class="com.sjy.subsys.web.HelloWithOutModeController"  
	p:supportedMethods="GET" p:requireSession="true" p:cacheSeconds="10" />

大家都看见了,像这样配置一下,我们就可以给浏览器加缓存了

但是有的人说了,这个也不好使呀,我按F5,每次都刷新

我就是这个感觉,所以我写了个小程序验证了一下

public static int idx = 0;

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		response.getWriter().write("hello" + idx++);

		return null;
	}

每次跟我hello的人都不一样,这是为什么呢?

其实是这样的,这个你点击链接的时候才会缓存,不是你按F5的时候

那么我们就想问了,这按F5和点击链接,到底有啥区别呢

我们下回再续

猜你喜欢

转载自sjy-showtime.iteye.com/blog/1965372
今日推荐