OmniFaces CacheControlFilter has no effect when response contains Content-Disposition header

178 views Asked by At

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?

1

There are 1 answers

1
BalusC On

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.