1

I performed the following steps:

  1. Converted javascript file to gzip file using 7-ZIP

  2. Enabled static compression in IIS

  3. Changed <script type="text/javascript" src="js/base.js"></script> to <script type="application/x-gzip" src="js/base.js.gz"></script>

Using firebug I check that base.js.gz response is empty.

3
  • 2
    The type of your script should still be text/javascript and not application/x-gzip. Commented May 3, 2011 at 9:09
  • 2
    I'm not sure you can actually zip the files yourself. The compression relies on a http header (content-encoding) to tell the browser to decompress it and treat it as a regular js-file. Commented May 3, 2011 at 9:12
  • If I use text/javascript gives an illegal character error. Commented May 3, 2011 at 9:13

3 Answers 3

4

That is not how you do it.

Leave your files alone and simply turn on static compression in IIS - that's it.

Sign up to request clarification or add additional context in comments.

2 Comments

How do I check if the files are really being compressed? I'm using YSlow and continues to say that the files are not compressed.
Then they aren't - simply check the HTTP-headers. There are plenty of guides available on how to enable compression eg: iis.net/ConfigReference/system.webServer/httpCompression
2

You are both compressing the file manually, and using IIS. If you got that to work, it would be compressed twice, which the browser can't handle.

Just use the compression in IIS, it will compress the files on the fly and send the correct HTTP header so that the browser knows to decompress it.

Comments

0

I think you need to rethink your approach. In order to enable gzipped content for static filetypes in IIS7 all you need is this in web.config:

<system.webServer>
    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />              
        </staticTypes>
    </httpCompression>
<system.webServer>

2 Comments

Well, you need a web.config nevertheless. I don't think this is even part of ASP.NET.
You're right, I only worked with web.config in ASP.NET but it applies to all web servers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.