Solved

Meaning of cacheSeconds in AbstractController

Posted on 2014-04-04
1
432 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iterator/ListIterator approach 17 24
eclipse buid path vs tomcat lib path 10 22
throw exception 21 42
CSV file parsing thru Java 13 26
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now