Forcing Compression

M

MattC

Hi,

If I add the following line to Application_BeginRequest

Request.Headers.Add("Accept-Encoding", "gzip");

Will this cause the server to utilise IIS6.0 Compression even if the client
is not set to use HTTP 1.1. Does the browser need to know that it sent the
request in HTTP 1.1 in order to decompress or can it determine from the
Response header that it needs to enflate/unzip.

TIA

MattC
 
?

=?ISO-8859-1?Q?Anders_Nor=E5s?=

MattC said:
Hi,

If I add the following line to Application_BeginRequest

Request.Headers.Add("Accept-Encoding", "gzip");

Will this cause the server to utilise IIS6.0 Compression even if the client
is not set to use HTTP 1.1.
No. The code will only add the header. To enable compression for ASP.NET
with IIS6.0 do the following:
1) Follow the steps described here:
http://www.microsoft.com/technet/pr...er2003/proddocs/standard/qos_utilbandwdth.asp
2) To set ASPX as a compressible extension, you'll have to edit the
metabase. Open "%windir%\System32\inetsrv\MetaBase.xml". Search for
"IIsCompressionScheme". There will be two XML elements, one for deflate
and one for gzip. Both elements have properties called HcFileExtensions
and HcScriptFileExtensions. These contain a space-delimited list of file
extension for compressible content. You'll need to add ASPX to the
HcScriptFileExtensions list. If the properties are left blank, then all
content, regardless of file extension, will be compressed.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
M

MattC

Ah, sorry guys, need to remember to be more precise.

Ok, HTTP compression is enabled/setup on IIS6.0 and working on all machine
with IE6 using HTTP 1.1.

However, I have about 50-60 laptop users on Win98 with IE5.5 using HTTP1.0.

So, my question was asked in the context of whether me adding the code will
force this setting onto the request regardless or whether the browser has to
have it set.

Thanks
MattC
 
B

bruce barker

its a two way street. adding the request header at the server, tell the
browser that it can post in compressed format if it wants to (not required).
in order for the server to send compressed to the browser, the browser need
to send the same request header, so the server knowns the browser can handle
it.

to use compression, the browser must use http 1.1 for the request, and send
the compression accept header.

-- bruce (sqlwork.com)



| Hi,
|
| If I add the following line to Application_BeginRequest
|
| Request.Headers.Add("Accept-Encoding", "gzip");
|
| Will this cause the server to utilise IIS6.0 Compression even if the
client
| is not set to use HTTP 1.1. Does the browser need to know that it sent
the
| request in HTTP 1.1 in order to decompress or can it determine from the
| Response header that it needs to enflate/unzip.
|
| TIA
|
| MattC
|
|
 
S

Simon Green

Some browsers will handle compressed content even if they didn't ask for
it (eg. Opera) but some refuse to decode it even if it does contain the
correct headers.

When it's configured to use HTTP/1.0 IE does not send the
Accept-Encoding header to indicate that it will accept compressed
content and if a compressed response is returned it will *not* be
uncompressed even if it has the correct Content-Encoding header.

It's possible to have a more 'aggressive' approach and apply compression
based on the User-Agent but lots of other things have to be taken into
account as well (firewalls that strip the headers, proxies that upgrade
or downgrade the request and so on).

So, it's normally simpler and safer to just go off the Accept-Encoding
headers which is the "official" way the content negotiation works (to
the HTTP spec).

- Simon Green
InteSoft.NET
http://www.intesoft.net

ASPAccelerator.NET - speed up your website and save bandwidth.
ASPRedirector.NET - put a friendly face on your website.
 
M

MattC

Ok thanks guys, as I only have to deal with IE I guess I will suggest that
the browsers be set to use HTTP1.1.

MattC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top