我目前是网络编程新手,正在尝试学习 spring 框架。我对 Servlet 和 JSP 有基本的了解。
目前,我对 Spring Controller 上的属性 cacheSecond 感到困惑。有人能给我指出可以理解以下概念的资源吗?
我阅读了一些关于浏览器缓存的内容,但我不确定这是否与 Spring 文档中提到的响应缓存相同
最佳答案
这记录在 API 中:
Cache content for the given number of seconds. Default is -1, indicating no generation of cache-related headers.
Only if this is set to 0 (no cache) or a positive value (cache for this many seconds) will this class generate cache headers.
The headers can be overwritten by subclasses, before content is generated.
这仅与 HTTP 缓存 header 相关,从而影响浏览器行为。它与服务器端响应缓存无关。
顺便说一句,如果您刚刚学习 Spring,我建议您避免使用可追溯到 Spring 2.0 的 Controller 类层次结构,而将重点放在 Spring 2.5 风格 annotated controllers 上。 。它更加直观和灵活,是现在编写 Spring MVC 应用程序的推荐方式。
关于java - Spring 模块中的 CacheSecond,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1899784/