Reputation: 275
The task that we are trying to solve is to set custom response headers for static resources (e.g. Cache-Control
) that are exposed in OSGi environment using HttpService.registerResources() method.
What is the best away to achieve this goal given the following details:
Solutions that we have in mind are:
Set response headers in HttpContext.handleSecurity
Register filter for each registerResource()
call using the same URI as the resources URI. Filter will be response for setting response headers.
Register one filter on the root path and configure it to set response headers if request URI correspond to a known resource URI path.
We are eager to hear opinions on the suggested solutions and know other alternatives.
Upvotes: 3
Views: 895
Reputation: 2359
The Equinox Jetty based HttpService implementation already supports If-None-Match
and If-Modified-Since
request headers for all resource registrations out of the box.
However, if it really needs to be framework agnostic and compliant with the HttpService standard and you are registering your resources programmatically anyway then I suggest writing your own servlet (eg. like the one from Equinox) which handles resource requests. Instead of using registerResources
directly wrap any resource registration using this servlet and registerServlet
. You can implement any caching strategy there.
Upvotes: 2