2

I'm planning on converting an ASP.NET MVC web site to ServiceStack Razor, with the aim of hosting it on a Linux server.

What would be the best solution for serving the static content of the site? Would a self hosted daemon behind Nginx be OK, or should I use Nginx to serve that directly? What are the benefits/disadvantages with using Mono FastCGI?

dabide
  • 996
  • 1
  • 6
  • 18

2 Answers2

1

If you have an opportunity to, serve static files with nginx, that would always be the most efficient option.

It's also what www.servicestack.net does with a lot of their Live Demo's.

mythz
  • 141,670
  • 29
  • 246
  • 390
1

I agree with mythz, and do this too, however you should also consider allowing caching of these static files to speed up browsing for your clients and reduce load on your servers.

In my nginx configuration, I define the common static types to serve up directly (allowing browser side caching), and then version all references to those types with a version query string to force refreshes when new copies are needed (i.e., /style.css?version=2)

Example:

location ~* \.(htm|html|jpg|jpeg|png|ico|txt|css|js|ico|pdf|gif|ttf|woff|svg|pdf)$ {
     #server it directly, but allow caching
     expires 30d;
}
JesseP
  • 756
  • 1
  • 7
  • 23
  • Sounds like a very good idea! Do you manually add the version query string? – dabide Apr 05 '13 at 23:35
  • Thanks. I'm actually in .NET so not sure how it transfers to your setup, but I actually pull my assembly version string and update it in to all the resources at run-time. That way if I bump to a new version for a release, all the static resources force a refresh and I won't forget to bump the versions. :) You could do it manually though... – JesseP Apr 07 '13 at 20:25