Compress html pages with gzip

Need help? Post your questions here.

Moderator: moderators

Compress html pages with gzip

Postby Matts » Mon Jun 11, 2012 10:54 am

Hi,

I've seen in the Subsonic 4.0.beta1 - Apr 23, 2010 changelog : "Tech: Compress html pages with gzip."

However, when I have a look at http headers or use a test-site like http://www.whatsmyip.org/http-compression-test/ or http://www.gidnetwork.com/tools/gzip-test.php , it seems that the pages sent by Subsonic are not gzipped.

Is there something I should do to enable this feature ? Did I miss something ?

(I'm using Subsonic directly with jetty)

Thanks,
Matt's
Matts
 
Posts: 18
Joined: Sat Nov 15, 2008 2:07 pm

Re: Compress html pages with gzip

Postby ytechie » Mon Jun 11, 2012 9:14 pm

I don't think the current subsonic pages are compressed. I think that the more important thing right now is to remove the whitespace caused by the jsp. There is a way to remove the whitespace in java containers, but I have not been able to get it to work. Instead - and I know this sounds crazy - I spent a few hours carefully minimizing the main pages and putting everything on one line. While this did speed up my load times a bit, it is not very practical and wouldn't be necessary if we found a way to get rid of the whitespace caused by jsp.
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Compress html pages with gzip

Postby Matts » Mon Jun 11, 2012 9:44 pm

I managed to enable gzip compression by modifying jetty/nnnn/webapp/WEB-INF/web.xml, adding :

Code: Select all
  <filter>
    <filter-name>GzipFilter</filter-name>
    <filter-class>org.mortbay.servlet.GzipFilter</filter-class>
    <init-param>
      <param-name>mimeTypes</param-name>
      <param-value>text/html,text/plain,text/xml,application/xhtml+xml,text/css,application/javascript,image/svg+xml</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>GzipFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>


ytechie, to my opinion, removing whitespaces to reduce bandwidth usage will be a lot less efficient than enabling compression. Maybe you can try my solution and tell me how it works for you?

Sindre, perhaps could you include this filter into the war's web.xml, so compression will be enabled by default ? (and so I will not have to re-enable it everytime I upgrade Subsonic ;))
And, just being curious, what was the modification you made to Subsonic when you added "Compress html pages with gzip." to 4.0 changelog ?
Matts
 
Posts: 18
Joined: Sat Nov 15, 2008 2:07 pm

Re: Compress html pages with gzip

Postby ytechie » Tue Jun 12, 2012 2:59 am

Does compression only help with bandwidth, or does it speed up load time as well?
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Compress html pages with gzip

Postby hakko » Tue Jun 12, 2012 4:48 am

Modern JSP engines have a possibility to pre-compile the pages and remove whitespaces. It actually makes quite a difference.
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: Compress html pages with gzip

Postby ytechie » Tue Jun 12, 2012 9:25 am

hakko wrote:Modern JSP engines have a possibility to pre-compile the pages and remove whitespaces. It actually makes quite a difference.


That's what I thought, but I could not get Jetty to do it. It is supposed to be pretty simple - it is a filter.
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Compress html pages with gzip

Postby hakko » Tue Jun 12, 2012 9:44 am

When I looked into it, I made a note that Subsonic uses Jetty version 6, which is getting old and now is in maintenance mode. The current JSP support is based on jasper 6.0.13 from Apache Tomcat, which doesn't support precompilation of JSPs. So you'd probably need to upgrade Jetty and start using Glassfish support for JSP 2.1 instead.
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: Compress html pages with gzip

Postby Matts » Tue Jun 12, 2012 1:16 pm

ytechie, compression helps for both bandwith and load time, because if less information goes through the network, the browser will get the data he needs quicker, so load time will be shorter.

I've done some informal tests (with browser's cache disabled) and my feeling is that the load time gain is significant, especially for the left panel, in which I have a lot of artists.
Matts
 
Posts: 18
Joined: Sat Nov 15, 2008 2:07 pm

Re: Compress html pages with gzip

Postby ytechie » Tue Jun 12, 2012 7:20 pm

The left panel was slow until 4.7. What version of subsonic are you using?
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Compress html pages with gzip

Postby Matts » Tue Jun 12, 2012 7:37 pm

4.7.beta2 (build 3011)
Matts
 
Posts: 18
Joined: Sat Nov 15, 2008 2:07 pm

Re: Compress html pages with gzip

Postby ytechie » Tue Jun 12, 2012 11:30 pm

So you got compression to work successfully. If we add minimization which includes whitespace removal, we could speed it up even further!

But here is another idea that I was thinking of. How about the ability to not load any artists in left.jsp. When you click on a letter the artists for that letter are loaded.
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York


Return to Help

Who is online

Users browsing this forum: No registered users and 27 guests