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.

realshadow
  • 121
  • 4
  • 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. – Shane Madden Feb 25 '12 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 '12 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? – Shane Madden Feb 25 '12 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 '12 at 21:57
  • Nothing? How's the PHP getting executed then? – Shane Madden Feb 25 '12 at 21:58
  • I meant nothing that has something to do with deflate, except loading the module itself – realshadow Feb 25 '12 at 22:10
  • `mod_deflate` doesn't exist in a vacuum, nor does this htaccess file - the differences in headers between the different content types (especially the chunked encoding) is a telling sign that the content types (which are handled 100% identically in this htaccess file) are being handled differently. The rest of the config is certainly relevant. – Shane Madden Feb 25 '12 at 22:17
  • Turns out everything is set up just like it should be. Problem is in ISA firewall, it removes Accept Encoding: gzip from headers on every js file – realshadow Feb 27 '12 at 18:02
  • Hah! That's brilliant. Good find! – Shane Madden Feb 27 '12 at 18:27

1 Answers1

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
pjmorse
  • 1,450
  • 1
  • 17
  • 34
  • 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 08 '12 at 09:04
  • Well, that would do it, yes. I guess I should've read all the comments above. – pjmorse Mar 08 '12 at 18:47