Is it somehow possible to define cache control level for each resource?
Is there some annotation i could put on top of each Resource class so to specify cache control in a custom way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To solve this issue I ended up defining an
@Cacheaspect. There are a couple of caveats that I ran into:The cached method needs to return a
Responseobject (not POJOs) so that the aspect can modify the headers.If you want to use ETags then the class containing the method (or the method arguments themselves) needs to expose the
@Requestso that the aspect can inspect the incoming tag.Make sure that your method arguments combined with your method name will in fact create unique keys. Another catch here is response type. The client may issue two requests with identical parameters but different response types.
You could easily add options to the aspect to control
max-ageand other parameters on a per-method basis.Here’s my
invokemethod: