Xsendfile And Cache

Hi guys,

I use XSendFile to serve images and videos which require to be logged in to be viewed.

My problem is that the client (Firefox, Chrome, Safari, …) does not cache the content sent through XSendFile.

This is not optimal as it will consume a lot of bandwidth.

I have spent many hours searching on Google for a solution. And I cannot find one.

So I ask you is there anyway to make XSendFile sending the correct header for client caching?

Thank you,


Try to use the CHttpCacheFilter.


Sorry for my late, very late, reply. Thank you for the answer.

Finally I have use the xSendFile method ‘addHeaders’ option to add some header:

Pragma: private // do not want my file to be stored in proxies

Cache-Control: maxage=<ttl>

Expires: <expires date>