Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Meaning of cacheSeconds in AbstractController

Posted on 2014-04-04
1
435 Views
Last Modified: 2014-04-14
Hi,
what does cacheSeconds when we extend an Abstract Controller.
I found some explanation here -
http://docs.spring.io/spring/docs/2.5.x/api/org/springframework/web/servlet/mvc/AbstractController.html

But couldnt understand it. Please provide some example with explanation.

What is a cache header or header and its use ?

Thanks
0
Comment
Question by:Rohit Bajaj
1 Comment
 
LVL 35

Accepted Solution

by:
girionis earned 500 total points
ID: 39988094
This property indicates to the client how long for it should cache the content.

cacheSeconds = -1 means that no headers will be generated.
cacheSeconds = 0 means that no caching is allowed.
cacheSeconds > 0 means that the controller will send the appropriate headers to indicate that the content shall be cached for that many seconds.

For example with cacheSeconds = 0 the controller will send the following with the response

Pragma: No-cache
Expires: n (where n is the current system date + 30, as HTTP formatted date) (HTTP/1.0)
Cache-Control: no-cache (HTTP/1.1)
Cache-Controle: no-store (HTTP/1.1, for Firefox)

Open in new window


With cacheSeconds = 30 the controller will send the following with the response

Expires: n (where n is the current system date + 30, as HTTP formatted date) (HTTP/1.0)
Cache-Control: max-ages=30 (where the max-ages is the time the content should be cached for) (HTTP/1.1)

Open in new window


Note that the client might ignore all of these headers, so setting them hints to the client your intention, it does not instruct it.

For more information you can read the book "Expert Spring MVC and Web Flow"
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
CSV file parsing thru Java 13 34
Java 8 to Java 6 8 20
jsp error 6 25
maven not picking latest jar instead picking old jar from .m2 12 17
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question