Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to setup a really fast, compressed, cached static content website to serve only .jpg, .css and .js

I want to remove all functionality from the website configuration that is not required:

But this configuration keep failing:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
     <urlCompression doStaticCompression="true" doDynamicCompression="false" />
    <caching enabled="true" enableKernelCache="true">
      <profiles>
        <add extension=".gif" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
        <add extension=".png" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
        <add extension=".js" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
        <add extension=".css" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
        <add extension=".jpg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
        <add extension=".jpeg" policy="DontCache" kernelCachePolicy="CacheUntilChange" duration="0.00:01:00" location="Any" />
      </profiles>
    </caching>
    <staticContent>
      <remove fileExtension=".js" />
      <mimeMap fileExtension=".js" mimeType="text/javascript" />
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
    </staticContent>
        <modules>
            <clear />
            <add name="HttpRedirectionModule" lockItem="false" />
            <add name="StaticFileModule" lockItem="false" />
            <add name="CustomLoggingModule" lockItem="false" />
            <add name="CustomErrorModule" lockItem="false" />
            <add name="IsapiModule" lockItem="false" />
            <add name="AnonymousAuthenticationModule" lockItem="false" />
        </modules>  
</system.webServer>
</configuration>
share|improve this question

1 Answer 1

up vote 2 down vote accepted

You didn't really say what is failing or provide error messages - but I am going to go out on a limb and take a guess.

My guess is that when you are doing the <clear /> within modules you are getting a "Lock Violation" error. This is because at the higher level of the IIS7 settings hierarchy, the modules section (and individual modules themselves) are set as locked so that you cannot override/remove them within a web.config file. This is by design, since the modules are really what make up a running IIS system.

To be able to do a <clear /> of modules in web.config, you need to do the following:

  • Make a backup copy of %windir%\System32\inetsrv\config\applicationHost.config
  • Open up %windir%\System32\inetsrv\config\applicationHost.config - you will need to open your editor as an administrator. Also, if you are on 64bit Windows, you will need to use a 64bit editor in order to see the file.
  • Find the <configSections> area - in the sectionGroup for system.WebServer - there will be a line that says:
    <section name="modules" allowDefinition="MachineToApplication" overrideModeDefault="Deny" />
    Change the overrideModeDefault to be Allow instead of Deny.

This still won't let you do a <clear /> in the web.config/modules though, because many of the core modules are locked individually.

  • Now look for the <modules> section in applicationHost.config.
  • Many of the modules listed here have the lockItem attribute set to True. Change them all to be False.
  • Save your applicationHost.config.

You should now be able to <clear /> modules in your web.config file.

share|improve this answer
    
+1 - Nice that you pointed out the 64-bit app requirements! –  Dscoduc Feb 24 '10 at 19:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.