[Resolved] Compressed XML Request

Status
Not open for further replies.

bh-tech

Well-Known Member
#1
We have pages on our server that use extensions like .php/.cgi along with parameters like 'xml=true' to create XML versions of the content.
So a URL like
Code:
www.example.com/search.cgi?xml=true
None of these XML type pages are being returned compressed when requested in a browser.
All pages have the Request Header 'Accept-Encoding: gzip, deflate, br', but are not returned with the expected Response Header 'Content-Encoding: gzip'

Is it possible to have these requests returned compressed?

I've attempted changes to our .htaccess file, but nothing seems to be working.
I've attached our GZIP Compression Settings in LiteSpeed.
GZIP Compression.png

The XML type pages include a Request Header of:
Code:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Whereas the Response Header for the page has:
Code:
Content-Type: text/xml; charset=UTF-8
Could the issue be the Content-Type doesn't match any of the Accepted types?
 
Last edited by a moderator:

bh-tech

Well-Known Member
#2
I've run quick test offline and can confirm that if I change the Content-Type to 'application/xml' the request is returned with gzip compression.

So I either need to change the Content-Type of the XML document, or change the Request Header to Accept text/xml as a compressable type.

How can I change the Request Header to Accept 'text/xml'?
 

bh-tech

Well-Known Member
#4
Unfortunately I don't have access to the php file to make those changes as it's encrypted.

Why would 'application/xml' compress, but not 'text/xml'?
 

bh-tech

Well-Known Member
#6
I understand it should be - but it's not.
I have looked at three different XML feeds and all have the 'text/xml' Content Type and all do not get compressed. So it can't be specific to each file, there must be a server settings somewhere that is overriding the Compressible Types set in LiteSpeed

Is that possible?
 

NiteWave

Administrator
#7
looks I can reproduce the issue.
server side:
Code:
#cat info.php
<?php
header("Content-Type: text/xml");
phpinfo();
?>
response headers:
Code:
Accept-Ranges:bytes
Connection:Keep-Alive
Content-Type:text/xml;charset=UTF-8
Date:Wed, 17 May 2017 09:12:44 GMT
Server:LiteSpeed
Transfer-Encoding:chunked
X-Powered-By:PHP/5.6.30
after I add text/xml to end of
Compressible Types: text/*,application/x-javascript,application/javascript,application/xml, image/svg+xml
response headers:
Code:
Accept-Ranges:bytes
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:21321
Content-Type:text/xml;charset=UTF-8
Date:Wed, 17 May 2017 09:19:08 GMT
Server:LiteSpeed
Vary:Accept-Encoding
X-Powered-By:PHP/5.6.30

Content-Encoding:gzip
is there.
 
Last edited by a moderator:

mistwang

LiteSpeed Staff
#8
text/xml is not pre-defined MIME type, so text/* wont pick it up. you can add it explicitly in the compressible type like you did, or add a MIME type.
 

bh-tech

Well-Known Member
#10
I added the 'text/xml' type to the list of Compressible Types and can confirm the requests are now returned gzipped.
Went from 20kb request to 6kb - pretty good!
 
Status
Not open for further replies.
Top