Solved

Meaning of cacheSeconds in AbstractController

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

708 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

21 Experts available now in Live!

Get 1:1 Help Now