java - Spring 模块中的 CacheSecond

标签 java spring caching spring-mvc

我目前是网络编程新手,正在尝试学习 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/

相关文章:

java - Hibernate 多次使用 Generatornames

java - 初学者 : Springs with Hibernate 4 doubts

java - spring data mongodb调用save两次导致重复键异常

java - Hibernate 从 4.3.x 迁移到 5.x 方法 org.hibernate.cache.spi.GeneralDataRegion.get(Object key)

c++ - DLL缓存问题

java - Swing中设置JComboBox的文本大小

Java 静态方法、通配符/通用返回类型

java - Java中character与int的转换

java - 如何在调试和 Release模式下从不同位置加载 Spring beans xml 配置

php - 使用 Varnish 缓存动态页面