Description
Craig Walls opened SPR-8550 and commented
Even though WebContentInterceptor can be used to declare when and how cache-control headers are set in a response, it isn't as straightforward or consistent with the @Controller
model.
I propose an annotation-based option for declaring when cache-control headers are added to a response. For example, a general-purpose @CachePolicy
annotation might be used like this:
@CachePolicy(maxAge=60)
@RequestMapping(value="/headlines", method=RequestMethod.GET)
public String showHeadlines() { ... }
Also, perhaps a more specific-purpose @PreventCaching
annotation might declare that a response include the headers currently added by WebContentGenerator's preventCaching() method.
These two annotations are just suggestions--I'd be interested in any solution that allows for declarative cache policies at the request method level.
Affects: 3.0.6
This issue is a sub-task of #16413
Issue Links:
- WebContentInterceptor.preHandle(request, response, handler), handler of type HandlerMethod not controller instance [SPR-9248] #13886 WebContentInterceptor.preHandle(request, response, handler), handler of type HandlerMethod not controller instance
- HTTP caching should be decoupled from WebContentGenerator [SPR-2779] #7466 HTTP caching should be decoupled from WebContentGenerator
- Add support for public/private Cache-Control HTTP header [SPR-7129] #11789 Add support for public/private Cache-Control HTTP header
- Regression: ShallowEtagHeaderFilter does not add Etag header for ResponseEntity returning methods [SPR-13717] #18290 Regression: ShallowEtagHeaderFilter does not add Etag header for ResponseEntity returning methods
Referenced from: commits f9ce11e
10 votes, 17 watchers