Output cache blocks image display from a custom module unless authenticated

Topics: Core, Troubleshooting, Writing modules
Sep 30, 2013 at 12:11 PM
We are developing a large web site using Orchard 1.7.

A custom module implements a controller to display images residing as blobs on an external SQL server database, something like:
http://localhost/Orchard.Web/immagini/display/7347?width=140

The database is accessed via NHibernate, sharing the session with Orchard; this has been done to benefit from the Orchard's caching mechanisms.

If Output cache module is disabled all works fine.

If I enable it (as reccomended):
a. the images does not display anymore navigating as anonymous user
b. if you authenticate yourself, images are displayed correctly

I read that Output cache does not cache "authenticated content", so i suppose this is the reason of point b.

Have we to decorate the controller action in some way to have the cache working correctly? Any suggestions?

Thanks in advance.