2

I have set up deflate in my htaccess. Everything works fine, except for some reason javascript files are being ignored. I tried every possible combination of AddOutputFilterByType DEFLATE with multiple mime-types but all without effect. Its not a caching issue, it actually let me believe it was working until I came home a double checked. Currently I am using this tool, site is here. You can clearly see that everything is compressed except js files (missing correct Content-Encoding unlike the js from google and css files).

Here is my current htaccess file:

<FilesMatch "\.(tpl|ini|log)">
    Order deny,allow
    Deny from all
</FilesMatch>

<FilesMatch "\.(js|css)$">
    SetOutputFilter DEFLATE

    # Netscape 4.x has some problems...
    BrowserMatch ^Mozilla/4 gzip-only-text/html

    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip

    # MSIE masquerades as Netscape, but it is fine
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

    # Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary
</FilesMatch>

ExpiresActive On
ExpiresDefault A0

<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
    ExpiresDefault A3024000
    Header append Cache-Control "public"
</FilesMatch>

<FilesMatch "\.(gif|jpg|jpeg|png|swf)$">
    FileETag MTime Size
    ExpiresDefault A3024000
    Header append Cache-Control "public"
</FilesMatch>

<FilesMatch "\.(xml|txt|html|js|css)$">
    FileETag MTime Size
    ExpiresDefault A604800
    Header append Cache-Control "proxy-revalidate"
</FilesMatch>

I had the DEFLATE filter out of file match as well.

Any help is appreciated, regards

Edit:

I already found the problem. Site is behind ISA firewall which removes "Content-Encoding: gzip" from js files.

9
  • Can you clarify what's going on in the rest of your congfig? What's served from where? Seems like your .css files are served out of PHP, since they're chunked encoding? And their Vary header seems.. off. Feb 25, 2012 at 21:14
  • The rest of it is for setting up expire and cache control headers for the different file types. As for css, its not served by php and neither is js (js is actually "served" by another js). As for why is it chunked, I have no idea...
    – realshadow
    Feb 25, 2012 at 21:37
  • I mean the config outside of the htaccess - can you provide more of it, or is this a shared hosting environment? Typically content generated dynamically is chunked; do your css files have a dynamic content handler doing anything with them? Feb 25, 2012 at 21:41
  • Its company webserver, I have access to everything. But at the moment I have nothing in httpd.conf or vhost config. CSS is as static as it can be. Funny thing is, that even after I have deleted those lines, css still comes gziped...
    – realshadow
    Feb 25, 2012 at 21:57
  • Nothing? How's the PHP getting executed then? Feb 25, 2012 at 21:58

1 Answer 1

1

Maybe the issue is your FilesMatch block. We've had success using AddOutputFilterByType instead.

# Compress output to save bandwidth and load faster
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
2
  • Thanks for your answer, but this wouldnt help either. I already found the problem. Site is behind ISA firewall which removes "Content-Encoding: gzip" from js files :)
    – realshadow
    Mar 8, 2012 at 9:04
  • Well, that would do it, yes. I guess I should've read all the comments above.
    – pjmorse
    Mar 8, 2012 at 18:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .