Help with GZIP

  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

I need help with compressing some files. I think GZIP is what I want to be doing, but I'm in a ASP/IIS environment. So, I don't have the cool Apache/PHP options seen here: http://elliottback.com/wp/http-gzip-compression-in-php/

I've tried IIS compression http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/d52ff289-94d3-4085-bc4e-24eb4f312e0e.mspx?mfr=true, but I didn't detect any improvement whatsoever.

What I need is to be able to GZIP some files. What I don't have is the know-how to accomplish that. I'm not a command line kinda guy so I was hoping to find a web/gui-based solution.

I found this, but the documentation looses me: http://www.gnu.org/software/gzip/manual/gzip.html.gz

Any tips on how to get started w/ GZIP?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

http://gnuwin32.sourceforge.net/packages/gzip.htm

gzip is a unix command. I use it on my FreeBSD box. The site above has a version for windows.
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Ok...I read the wikipedia on GZIP and that got me going...
http://en.wikipedia.org/wiki/Gzip

So, I've gzip'd a file from whatever.JS to whatever.JSZ

How do I make use of this *.JSZ?

I've tried both of these approaches with no luck
Code: [ Select ]
1. <script type="text/javascript" src="http://www.domain.com/whatever.js"></script>
2. <script type="text/javascript" src="http://www.domain.com/whatever.jsz"></script>
  1. 1. <script type="text/javascript" src="http://www.domain.com/whatever.js"></script>
  2. 2. <script type="text/javascript" src="http://www.domain.com/whatever.jsz"></script>
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

It's not going to be .jsz
It's going to be .js.gz by default. You can make it JSZ with the -S switch but you might have a problem decompressing it later

Keep it simple.

gzip -1 whatever.js

The -1 is for fast compression but you don't even need that.

Here's an example from my Unix box. I have a file called yogi.txt
queyosepa# gzip -1 yogi.txt
queyosepa# ls -asl |grep yogi
2 -rw-r--r-- 1 don wheel 391 Jan 7 20:16 yogi.txt.gz
queyosepa# gzip -d yogi.txt.gz
queyosepa# ls -asl | grep yogi
2 -rw-r--r-- 1 don wheel 583 Jan 7 20:16 yogi.txt
queyosepa#

First I compressed it. gzip -1 yogi.txt
Then I listed the files in the directory but only told it to show any files with the word yogi in it. The grep command did that. As you can see it gave it the .gz extension.
Then I decompressed it gzip -d yogi.txt.gz
That removed the .gz extension when it decompressed it.
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

when I did

Code: [ Select ]
gzip whatever.JS
it gave me whatever.JSZ

Do I need to add a "switch" to get the *.*.gz?
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

I just tried
Code: [ Select ]
gzip -1 whatever.JS
it told me whatever.JSZ already exists
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

So that means it worked the first time you did it. Don't forget that I'm not using the windows version, so there could be some differences.
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

If *.JSZ is correct...which I'm not convinced it is...then how do I use it?

s15199d wrote:
So, I've gzip'd a file from whatever.JS to whatever.JSZ

How do I make use of this *.JSZ?

I've tried both of these approaches with no luck
Code: [ Select ]
1. <script type="text/javascript" src="http://www.domain.com/whatever.js"></script>
2. <script type="text/javascript" src="http://www.domain.com/whatever.jsz"></script>
  1. 1. <script type="text/javascript" src="http://www.domain.com/whatever.js"></script>
  2. 2. <script type="text/javascript" src="http://www.domain.com/whatever.jsz"></script>


#1 Works. But, it's not compressed, obviously.
#2 Its like it doesn't ever find the file.


I also tried changing the extension from *.JSZ to *.JS.GZ manually
Code: [ Select ]
3. <script type="text/javascript" src="http://www.domain.com/whatever.js.gz"></script>


#3 I get "Illegal Character" javascript errors. Its like it couldn't unencode the file.
...

More info

When using Firefox to browse the *.JSZ I get a 404:File Not Found. When I use Firefox to browse to the *.JS.GZ it finds it.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

I'm not a big fan of the "on the fly" gzip methods in Apache like mod_deflate or mod_gzip. In my experience they reduce bandwidth usage but really don't do anything in terms of the number of requests per second the server can handle in my AB (Apache Bench) tests. I suspect the extra processing involved in compressing the content negates any benefits from the reduced transfer time.

I'm guessing your experience with IIS compression is the same. I haven't used IIS since Windows 2000 Server, so I really don't know how things are with it these days.

Have you used 7-zip before ?
If I remember right, 7-zip will let you right-click files and bring up some fairly simple options that will let you produce a gz file.

--

I just caught your "Illegal character" bit right before I posted this. My guess is that your server isn't sending a gzip Content-Encoding header with the file. So the browser doesn't know to decode it before parsing it.
  • Don2007
  • Web Master
  • Web Master
  • Don2007
  • Posts: 4924
  • Loc: NY

Post 3+ Months Ago

Let's start from the beginning. Why did you want to compress the file in the first place? I just did a quick search on google & apparently, using gzip to compress .js files isn't supported in IIS.

Look at the supported table at:

http://www.microsoft.com/technet/prodte ... 7d568.mspx

It could be that js-optimizer better fits your needs.

http://js-optimizer.sourceforge.net/
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

joebert: thanks for the tip on using 7-zip...that successfully generated *.JS.GZ So, creating the *.*.GZ is resolved. However, I'm still getting the illegal character JS error

Don2007: I'm going to take a look at the JS optimizer. I'm not sure how much help compression I'll get out of it. I'm trying to compress a large JSON data string...that's pretty much all that's in my JS file

Gzip took the file from 751kb down to 143kb...but as mentioned, JS doesn't like Gzip

I'll let ya know what I figure out.

Thank you both for your suggestions/feedback!!!
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Quote:
joebert: ... However, I'm still getting the illegal character JS error


Are you using Firefox ?
Do you have an HTTP Headers extension installed ? (for instance this one)

In any event, you need something that looks at the HTTP headers. Once you have that, navigate to the URL you're using as the src in your script. Does the response include a "Content-Encoding" header ?
What headers does it include ?

Post Information

  • Total Posts in this topic: 12 posts
  • Users browsing this forum: No registered users and 142 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.