Question

I have an ASP.NET webforms application (3.5 SP1) that I'm working on, and attempting to enable gzip fpr HTML and CSS that comes down the pipe. I'm using this implementation (and tried a few others that hook into Application_BeginRequest), and it seems to be corrupting the external CSS file that the pages use, but intermittently...suddenly all styles will disappear on a page refresh, stay that way for awhile, and then suddenly start working again.

Both IE7 and FF3 exhibit this behavior. When viewing the CSS using the web developer toolbar, it returns jibberish. The cache-control header is coming through as "private," but I don't know enough to figure out if that's a contributing factor or not.

Also, this is running on the ASP.NET Development Server. Maybe it'd be fine with IIS, but I'm developing on XP and it'd be IIS5.

Was it helpful?

Solution

Is it only CSS files that get corrupted? Do JS files (or any other static text files) come through ok?

Also can you duplicate the behavior if you browse directly to the CSS file?

I've only enabled compression on Windows 2003 server's IIS using this approach:

  1. IIS → Web Sites → Properties → Service tab, check both boxes
  2. IIS → Web Service Extensions → Right click, Add New
      Name
          Http Compression 
      Required Files
          %systemroot%\system32\inetsrv\gzip.dll 
  3. IIS → Right click top node, Internet Information Services, check Enable Direct Metabase Edit
  4. Backup and Edit %systemroot%\system32\inetsrv\MetaBase.xml
    1. Find Location ="/LM/W3SVC/Filters/Compression/gzip"
      • Add png, css, js and any other static file extensions to HcFileExtensions
      • Add aspx and any other executable extensions to HcScriptFileExtensions
      • Save
  5. Restart IIS (run iisreset)

If you have a Windows 2003/2008 server to play with you could try that approach.

OTHER TIPS

If you will be deploying on IIS 6 or IIS 7, just use the built-in IIS compression. We're using it on production sites for compressing HTML, CSS, and JavaScript with no errors. It also caches the compressed version on the server, so the compression hit is only taken once.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top