Skip to content

Provide controller method level alternative to WebContentInterceptor [SPR-8550] #13194

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits f9ce11e

10 votes, 17 watchers

Metadata

Metadata

Assignees

Labels

has: votes-jiraIssues migrated from JIRA with more than 10 votes at the time of importin: webIssues in web modules (web, webmvc, webflux, websocket)type: taskA general task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions