Skip to content

HTTP caching should be decoupled from WebContentGenerator [SPR-2779] #7466

Closed
@spring-projects-issues

Description

@spring-projects-issues

Matthew Sgarlata opened SPR-2779 and commented

The WebContentGenerator class has several methods that help manage HTTP caching for controllers (cacheForSeconds, preventCaching, etc). These methods are great for controllers that extend from WebContentGenerator (or one of its subclasses like AbstractController) but are unavailable if you have a controller that doesn't want to or can't extend from WebContentGenerator or one of its subclasses. It's also unavailable if you are using a HandlerInterceptor to catch exceptions and forward to a special exception view.

I recommend the HTTP caching methods be moved into a new class to which WebContentGenerator delegates. The new class could be called HttpCacheHelper or something similar.

I ran into this in my application because we have HandlerInterceptors that redirect to JSPs if certain conditions are met. For example, if a user doesn't have the correct permissions to view a page a HandlerInterceptor sends them to a page that lets the user know they don't have permission to view the page they requested.

This is also a problem with ExceptionResolvers. They currently do not offer an easy way to work with HTTP caching out-of-the-box. I will open a separate bug report for that.


Affects: 2.0 final

This issue is a sub-task of #16413

Issue Links:

Referenced from: commits 38f32e3

0 votes, 6 watchers

Metadata

Metadata

Assignees

Labels

in: 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