I have searched for solution, and what I found out so far:
Hosting static content directly using
nginx
oriis
. They are built to serve static files efficiently.For
NancyFx
there is aStaticContentConventionBuilder
For
OWIN
app there is aStaticFileMiddleware
Custom static handler: stream file from file system per each request (with old
etag
) and manually handleetags
,last-modified
andcache-control
headers.
Because of my constraints I can't (or don't want to) use 1-3 options.
I think option 4 is not good one (please, correct me, if I'm wrong) because it's expensive to operate with file system. So I want to reinvent the wheel and create efficient static content handler (with caching files content in memory, file system watching etc) or find other solutions.
I looked over docs and source code of managing static content in NancyFx
and StaticFiles in OWIN
. Both actually are similar to option 4. Why are these methods considered to be efficient?
How to efficiently (customly) serve static files in .NET?