23

In Apache Im enabling output compression by adding the following to my .htaccess file:

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>

So I'm serving all content with Content-Encoding: gzip but when I test my webpage with Yslow I receive:

Grade D on Compress components with gzip

There are 3 plain text components that should be sent compressed

* http://mysite.com/javascript/youTubeEmbed/youTubeEmbed-jquery-1.0.css
* http://mysite.com/javascript/jquery.swfobject.1-1-1.min.js
* http://mysite.com/javascript/youTubeEmbed/youTubeEmbed-jquery-1.0.js

Where's the problem?Shouldn't they get compressed automatically??

thanks

Luca

luca
  • 36,606
  • 27
  • 86
  • 125

3 Answers3

28

Did you remember to clear your cache before reloading the page and running Yslow?

I had the exact same problem and fixed it like that. This is my code:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
akond
  • 15,865
  • 4
  • 35
  • 55
Jeff Gladnick
  • 624
  • 1
  • 8
  • 11
  • Somehow, I solved my problem by adding: stylesheet and script also, for google chrome (didn't check on other browsers) somehow Apache didn't recognized text/css nor any javascript variations but script in google chrome. – Paulo Lima Nov 22 '17 at 15:16
5

In my case, I resolved the exact same problem just adding this line to the .htaccess file: AddOutputFilterByType DEFLATE text/javascript

Maybe the server is not getting javascript as application/javascript but text/javascript. Hope it helps.

2

In my case, I had to remove the Reverse-Proxy-Server (nginx) - of course, you can also configure compression using the nginx.conf file (may be located in /etc/nginx or use an own .conf file located in /etc/nginx/conf.d directory) - but nginx caused some other problems. Having removed nginx from a Server using Plesk have a look at these hints: http://forum.parallels.com/showthread.php?t=260563 To cut a long story short: Take care wether the files are really served by your Apache or they are handled by something like nginx. B.t.w. a quick testing tool: http://www.gidnetwork.com/tools/gzip-test.php

Dominik Späte
  • 415
  • 5
  • 8