0

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
jpl
  • 347
  • 3
  • 11
  • 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 Answers1

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.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555