473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

GZip output compression with AJAX

Hi. To make page downloading quicker, I added GZipStream into the
Response filter. My (shortened VB) code snippet from Global.asax looks
like this:
............................................

Sub Application_BeginRequest(...)

If Request.RawUrl.Contains(".aspx") And _
Not Request.Headers("Accept-Encoding") Is Nothing Then

If Request.Headers("Accept-
encoding").ToLower().Contains("gzip") Then

Response.Filter = New GZipStream(Response.Filter,
CompressionMode.Compress, True)
Response.AppendHeader("Content-encoding", "gzip")

' Else...try deflate

End If

End If

End Sub
............................................

I added the check for .aspx in the request because it was messing up
images. Now that I'm using AJAX, it's giving me problems again. When
AJAX (I mean ASP's AJAX thing, but I'm not using Atlas) tries to
communicate with the server, it (JS) alert()s me that it could not
parse the server's response, and is probably because of a filter
(meaning this simple GZip stream).

How can I more efficiently check whether or not it is appropriate to
compress the output? And, by the way, is there a better way of
compressing output that won't mess up with images and could possibly
compress AJAX also?

-Mike PII

Jun 4 '07 #1
4 18705
Did you ever find a solution to this? I am having the same problem. If I
enable compression on our ISA server, it works fine. Just when using an
HTTPModule is when I have this problem. Very frustrating.

"Mike P2" wrote:
Hi. To make page downloading quicker, I added GZipStream into the
Response filter. My (shortened VB) code snippet from Global.asax looks
like this:
............................................

Sub Application_BeginRequest(...)

If Request.RawUrl.Contains(".aspx") And _
Not Request.Headers("Accept-Encoding") Is Nothing Then

If Request.Headers("Accept-
encoding").ToLower().Contains("gzip") Then

Response.Filter = New GZipStream(Response.Filter,
CompressionMode.Compress, True)
Response.AppendHeader("Content-encoding", "gzip")

' Else...try deflate

End If

End If

End Sub
............................................

I added the check for .aspx in the request because it was messing up
images. Now that I'm using AJAX, it's giving me problems again. When
AJAX (I mean ASP's AJAX thing, but I'm not using Atlas) tries to
communicate with the server, it (JS) alert()s me that it could not
parse the server's response, and is probably because of a filter
(meaning this simple GZip stream).

How can I more efficiently check whether or not it is appropriate to
compress the output? And, by the way, is there a better way of
compressing output that won't mess up with images and could possibly
compress AJAX also?

-Mike PII

Jun 6 '07 #2
On Jun 6, 8:50 am, bikemike <bikem...@discussions.microsoft.com>
wrote:
Did you ever find a solution to this? I am having the same problem. If I
enable compression on our ISA server, it works fine. Just when using an
HTTPModule is when I have this problem. Very frustrating.
No, I haven't found a solution yet. This is frustrating me too. GZip
compression is a pretty common thing, I'm sure it's been done
successfully in ASP.net and there are people in this newsgroup who
have the solution.

-Mike PII

Jun 6 '07 #3
Ok, I tried using

If Request.Headers("Accept").Contains("html") Or
Request.Headers("Accept").Contains("xml")) Then

instead to decide whether or not to compress the output with GZ and my
other filter that takes out some whitespace, but that's not helping
either. I guess ASP.net AJAX is served by the same page it's on
instead of ScriptResource.axd or whatever. So what can I do?

-Mike PII

Jun 11 '07 #4
I did find a solution to this problem that is not resolved with GZip in .NET,
but in IIS. Basically all I did was enable compression for only my virtual
directory in IIS. For whatever reason, the AJAX code does not have any
problems with this and it works great. I am getting nearly 90% compression
on my returned code now. After spending a day trying to make the .NET
solution work, I gave up and looked for alternative solutions. Fortunately,
the built-in IIS compression did the trick. If you need help on how to
enable it for just a single web or virtual, let me know.

"Mike P2" wrote:
Ok, I tried using

If Request.Headers("Accept").Contains("html") Or
Request.Headers("Accept").Contains("xml")) Then

instead to decide whether or not to compress the output with GZ and my
other filter that takes out some whitespace, but that's not helping
either. I guess ASP.net AJAX is served by the same page it's on
instead of ScriptResource.axd or whatever. So what can I do?

-Mike PII

Jun 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Xah Lee | last post by:
today i need to use Python to decompress gzip files. since i'm familiar with Python doc and have 10 years of computing experience with 4 years in unix admin and perl, i have quickly located the...
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
4
by: Anders K. Jacobsen [DK] | last post by:
Hi Does anyone have experience using gZip compression on the IIS server with a ASP.NET application. How much can a page be compressed. As i see it it must have a huge impact on the total size....
2
by: .nLL | last post by:
hi. i have recently enabled gzip compression on my server and it works fine. but i have noticed something wierd. To protect my self from hotlinking i use a simple code to send my download with...
2
by: Chaos | last post by:
I have tried to search Google, but I cannot seem to find a library to decompress a gzip string or char to a string or char. I want to write something that allows libcurl to access a page, save the...
4
by: mathieu | last post by:
Hello, Browsing the archive of this group I see that the c++ iostream wrapper that are shipped with zlib are not satisfying : ...
2
by: Carlo Razzeto | last post by:
Hello there, I'm having an odd issue with GZIP compression (having followed example code found on MSDN). Basically, after running through the compression routine I end up with a byte array...
3
by: Sean Davis | last post by:
I have a set of numpy arrays which I would like to save to a gzip file. Here is an example without gzip: b=numpy.ones(1000000,dtype=numpy.uint8) a=numpy.zeros(1000000,dtype=numpy.uint8) fd =...
6
by: Giorgio Parmeggiani | last post by:
Hi I'm using the gzip compression found in WCG samples kit. It works well, but how can I set the SendTimeout and ReceiveTimeout parameters? Thank in advance Giorgio
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.