It seems that cache directives are not applied when the resource response contains HTTP header Content-Disposition:inline. When we use OmniFaces CacheControlFilter the response doesn't contain Cache-Control or Expires directive. Is it normal?
Asked
Active
Viewed 155 times
0
-
More than often, response headers are reset by code intented to stream a file download. Are you sure this isn't the case here? – BalusC Dec 20 '16 at 16:29
-
Correct. there is a response.reset(); in the code – jpl Dec 20 '16 at 16:55
1 Answers
2
No, this is not the default behavior.
This behavior suggests that the code responsible for streaming the file has performed a response.reset() in order to ensure that the response is crisp and clean. You see this often in copypaste code snippets because starters otherwise complain that the download doesn't work. For example here: How to provide a file download from a JSF backing bean?
Given that you're using OmniFaces, you may probably find Faces#sendFile() or FileServlet more useful for the task of streaming a file to response. The Faces#sendFile() does not perform a response.reset(), and the FileServlet caches by default 30 days which is controllable by overriding the getExpireTime() method.