compression for JS files

Discussion in 'Apache' started by mummana, Dec 8, 2008.

  1. #1
    Hi,

    We are using mod_defalte module for the compression in apache. But we did not see the JavaScript files are not compress (gzip). But .css files compressing properly.

    Could you please check the below configurations and response header details for JS and CSS files.



    Pls. help me regarding.







    # Directives for compression. Very similar to the example configuration on the



    # mod deflate documentation page

    AddEncoding x-compress Z

    AddEncoding x-gzip gz tgz

    AddType application/x-tar ..tgz



    # Compress content

    SetOutputFilter DEFLATE



    # Don’t bother compressing images

    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary



    # Netscape Navigator version 4.x can handle only text/html

    BrowserMatch ^Mozilla/4 gzip-only-text/html



    # Specific Netscape versions having issues with all compression

    BrowserMatch ^Mozilla/4\.0[678] no-gzip

    BrowserMatch \bMSI[E]\W5 no-gzip dont-vary



    # Alert proxies of exclusions to compression based on browser type, uri type etc

    Header append Vary User-Agent



    Response Header for JS Files

    (Status-Line) HTTP/1.1 200 OK

    Server Apache

    Last-Modified Wed, 03 Dec 2008 15:18:34 GMT

    Etag "3a6b3-4854-f517e680"

    Accept-Ranges bytes

    Content-Type application/javascript

    Cache-Control public, max-age=291178

    Expires Fri, 12 Dec 2008 06:04:07 GMT

    Date Mon, 08 Dec 2008 21:11:09 GMT

    Content-Length 18516

    Proxy-Connection Keep-Alive

    Connection Keep-Alive

    Age 0



    Response Header for CSS Files

    (Status-Line) HTTP/1.1 200 OK

    Server Apache

    Last-Modified Wed, 03 Dec 2008 15:18:27 GMT

    Etag "3a6c7-8b2a-f4ad16c0"

    Accept-Ranges bytes

    Content-Type text/css

    Cache-Control public, max-age=604800

    Expires Mon, 15 Dec 2008 21:13:31 GMT

    Date Mon, 08 Dec 2008 21:13:31 GMT

    Vary Accept-Encoding

    Content-Length 8582

    Proxy-Connection Keep-Alive

    Connection Keep-Alive

    Content-Encoding gzip

    Age 0





    Best Regards,

    Srini
     
    mummana, Dec 8, 2008 IP
  2. thegetpr

    thegetpr Banned

    Messages:
    99
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    output_handler = zlib.output_handler activate this in your php.ini it will compress your output

    and write this just before your php code ob_start("ob_gzhandler");
    and last line after php code ob_implicit_flush(0);
     
    thegetpr, Dec 14, 2008 IP
  3. aekung

    aekung Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    wow! this i've been search for

    :D:D
     
    aekung, Jan 12, 2009 IP