Solved

Meaning of cacheSeconds in AbstractController

Posted on 2014-04-04
1
443 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
[X]
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
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

739 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