views:

464

answers:

2

I have and HTTP module that cleans, compresses and minifies CSS, JS, and HTML files based on their content type header. It works great in my staging environment and localhost (ISS7, classic pipeline mode). On IIS 6 (production), it is not reliable. Sporadically, this static files stop being processed by asp.net and appear to be reverting to the default IIS handler. If I touch the web.config or do an IISRESET it will start working correctly again, for a time. Even when the module gets into this "wacky state", .aspx files are still running through the module as expected. So, I am fairly certain that the module is not the issue, and that what we are looking at is an IIS problem.

  1. I have HTML, JS and CSS files mapped in IIS 6 to be processed by aspnet_isapi.dll for all verbs.
  2. In my web.config, I have set these static files to be handled by System.Web.StaticFileHandler in the handlers section also for all verbs.
  3. The HTTP Module is wired up in the web.config as well.

Any ideas? I'd like to avoid upgrading my production web server to IIS 7 for the time being!

A: 

A big difference between development and production is volume of traffic.

Volume can highlight concurrency issues not hit upon in low traffic development testing.

Are you sure your code is free of threading issues etc.

AnthonyWJones
I wish I had a volume problem! Unfortunately, my traffic is very sparse. I will definitely investigate this though.
smercer
+1  A: 

I would say with pretty high confidence that the problem lies in your HttpModule. Maybe the problem could be a threading issue. The HttpModule is only instantiated once for all requests, so if you store data in member variables in the class, you will have a problem as multiple threads will access the same data at the same time.

By the way, I think I would suggest an alternate solution to your problem. Create a build script, using e.g. MSBuild, and let the build script compress the files.

Pete
I have thought about doing this as part of the build process, but the module is also handling axd's and asmx script proxies that are generated at runtime. The funny thing with these non-static examples is that they work fine all the time. It's only the static files that occasionally fail to be processed by the module. I do have two member variables that I could change to constants (they are StringCollections that get populated in the module's constructor). I don't have much experience with multi-threaded apps, could those be suspect?
smercer
@smercer - If the only variables in the module are the two variables populated in the constructor, then those should not be to blame. But maybe firing off a lot of requests to one of these static files simultaneously can help indicate if it is a multithreading problem. But the worst part of multithreading problems is that they you can never be sure you don't have one just because you cannot recreate.f
Pete