Search code examples
javaspringspring-mvcjboss7.xpagespeed

PageSpeed "Enable Compression" in web application


I did the Pagespeed of my application in the chrome browser.Page score is 30 out of 100. Resulted couple of errors, out of few results. I am facing trouble in fixing the "Enable compression" for js and css.

I am using Spring MVC and jboss 7.1.1. I tried some configuration changes in the jboss standalone xml, but not worked.

<system-properties>
        <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION" value="on"/>
        <property name="org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES" value="application/javascript,text/javascript,text/css,text/html,text/xml,text/json"/>
    </system-properties>

<script type="application/javascript" src="${pageContext.request.contextPath}/dashboard-assets/scripts/daterangepicker.js"></script>

Please help me to resolve this issue.


Solution

  • Check for the correct Mime-Type.

    Your are using mine types to select which files get compressed. Have a look if these match up with the ones you are actually serving. This is available in the Chrome Network tab (or similar if using a different Browser)

    Mime Types from my Project are

    text/xml text/plain text/css text/javascript application/json application/javascript application/xml image/svg+xml
    

    Note that for JavaScript it is actually application/javascript.

    Serve Assets from a Webserver

    Depending of your setup you should have a look at serving assets (like images, js, css, fonts etc) from a Web Server like nginx or Apache httpd. These web servers are more capable of handling static files and it also means less traffic is sent to your application server.