cancel
Showing results for 
Search instead for 
Did you mean: 

Add support for HTTP compression in the builtin HTTP server

Breck_Carter
Participant
2,115

Here's a suggestion posted on the NNTP forum; I looks like A Good Thing...

On 20 Oct 2010 00:35:53 -0700, LM wrote:

Add support for HTTP compression in SQL Anywhere built in web server. See http://www.http-compression.com/ for details. It is a standard web technique, which reduces HTML traffic up to 4 times.

LM

Accepted Solutions (1)

Accepted Solutions (1)

graeme_perrow
Advisor
Advisor

I've added this to our "stuff to look into" list. Note that the website linked to doesn't exist - or at least it has no DNS entry.


From Breck: Allow me to retort...

C:\\Documents and Settings\\bcarter>ping www.http-compression.com

Pinging www.http-compression.com [213.239.195.236] with 32 bytes of data:

Reply from 213.239.195.236: bytes=32 time=153ms TTL=52
Reply from 213.239.195.236: bytes=32 time=152ms TTL=52
Reply from 213.239.195.236: bytes=32 time=155ms TTL=52
Reply from 213.239.195.236: bytes=32 time=154ms TTL=52

Ping statistics for 213.239.195.236:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 152ms, Maximum = 155ms, Average = 153ms


From Graeme:

Strange. Must be a Sybase thing:

[C:\\WINDOWS]ping www.http-compression.com
Ping request could not find host www.http-compression.com. Please check
the name and try again.

http://downforeveryoneorjustme.com/www.http-compression.com says it's up too.

Breck_Carter
Participant
0 Kudos

You actually thought I hadn't tested the link... more than once...?

Former Member

I'd say it must be a plot by the Corporate Internet Police...

reimer_pods
Participant

Maybe the site was temporarily unavailable while being compressed?

Answers (2)

Answers (2)

Former Member

Actually, it is possible so serve compressed HTTP content using current SA versions, but it requires some additional coding (see example below). So, a built-in HTTP compression would still be a more robust and usable solution. P.S. You can check if your page is compressed using this online tool: Port80 Software

CREATE FUNCTION "sp_client_accepts_encoding"(IN @Algorithm CHAR(100))
RETURNS INTEGER
BEGIN /* returns 1 if client (browser) accepts given HTTP compression algorithm (according to Accept-Encoding HTTP header values) */
    DECLARE @List LONG VARCHAR;

SELECT value INTO @List FROM sa_http_header_info('Accept-Encoding');
    IF EXISTS (select 1 from sa_split_list(@List) where row_value = @Algorithm) THEN
        RETURN 1;
    ELSE
        RETURN 0;
    END IF;

END

GO

CREATE FUNCTION "sp_compress_page_if_accepted"(IN @HTML_page LONG BINARY)
RETURNS LONG BINARY
NOT DETERMINISTIC
BEGIN
    IF sp_client_accepts_encoding('gzip') = 1 THEN // client (browser) accepts compression
        CALL dbo.sa_set_http_header('Content-Encoding', 'gzip');
        RETURN COMPRESS(@HTML_page, 'gzip'); // return compressed page
    ELSE
        RETURN @HTML_page; // return uncompressed page
    END IF;
END

GO

CREATE SERVICE "hello" TYPE 'RAW' AUTHORIZATION OFF USER "dba" AS 
SELECT sp_compress_page_if_accepted('Hello, world!');
Former Member
0 Kudos

Linas... clever stuff, but I'm totally with LM and Breck on this... If SQLA is a web server (which I guess it is), we shouldn't have write database functions to handle this. The web server should just 'know' to do this.

Another solution for current versions of SQL Anywhere is to sit the database server behind a Reverse Proxy that is capable of compressing the responses. E.g. Apache via mod_proxy or the latest versions of IIS (7.0 and 7.5).