0

I'm trying to speed up my Magento store and have recently enabled Gzip compression. The problem is, i also use the Magento in-built function that merges all CSS and JS files together to serve a single file for each.

The Gzip does not compress those files & since this is Magento, those files are enormous and slow down the site significantly.

Anything i can do that Gzip will also compress those files? They are located in /media/js/ and /media/css/

Edit: using mod_deflate, right now i have it set to this:

<IfModule mod_deflate.c>

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml
AddOutputFilterByType DEFLATE application/javascript application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:pdf|doc)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:avi|mov|mp3|mp4|rm)$ no-gzip dont-vary

3
  • Are you really sure those files slow down your site? If caching is configured correctly, those resources should be requested only once by each client. Commented Dec 8, 2011 at 20:12
  • 1
    Check out fooman speedster. Awesome extension that handles all of this for you. Commented Dec 8, 2011 at 20:28
  • mod_deflate should compress all content, even the php-generated ones. Is magento sending the correct MIME headers for css and js? Commented Jan 14, 2012 at 22:08

3 Answers 3

3

When Magento merges any CSS and Javascript files that pass through its rendering system, it will create URLs for those resource like this, and add them to the head of the page

http://magento1point6point1.dev/media/css/a438f0287fdd0c52d9bd196d355a63c3.css
http://magento1point6point1.dev/media/js/0567fb98ebe279ea4faf5acf433fc6a1.js

in turn, this will generate files on the filesystem

media/css/a438f0287fdd0c52d9bd196d355a63c3.css
media/js/0567fb98ebe279ea4faf5acf433fc6a1.js

At this point, Magento is removed from the process almost completely (there's a RewriteCond %{REQUEST_URI} !^/(media|skin|js)/ in .htaccess to catch non-existant files). It sounds like you have gzip compression setup correctly for other areas of the site. So, however you've configured other folders for gzip compression, configure media/css and media/js to do the same.

Without more information, it's impossible to debug your system further.

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks. Edited my first post to provide some more info, attached my htaccess file excerpt, using mod_deflate to compress, but don't know how to include that directory to also be compressed.
@SarthakGupta If you'd used 5 question marks someone might have been able to help. With only three I don't think we'll be able to solve it.
The site I am working on is collectorsheritage.com . I am using HTTP live headers to assess the compression (if any). While the html files are getting compressed the same is not happening with my merged js and css files. Another important thing is I have fooman Speedster module installed and running already.
Hi @AlanStorm I am trying to understand this correctly. In the last bit of your reply "It sounds like you have gzip compression setup correctly for other areas of the site. So, however you've configured other folders for gzip compression, configure media/css and media/js to do the same." What do you mean by that exactly? I thought setting DEFLATE in root would count for all filetypes in any directory (under root). Thanks!! Can you elaborate a little?
can someone elaborate on what is needed here? My YSlow indeeed confirms that the media/*/js and media/*.css are not being gzipped .... but how to tell htaccess to gzip these two?
|
0

You can use Apache's http://httpd.apache.org/docs/2.0/mod/mod_deflate.html module.

1 Comment

Thanks, im already using it, edited my first post to add the excerpt from .htaccess, i just don't know how can i include files from /media/css/ and /media/js/ to also be compressed.
0

For anyone experiencing the same issue: First try to refresh your browser cache.

Google Chrome PageSpeed Insights was telling me that the merged css and js files of my Magento store were not compressed, although I had GZIP enabled and configured .htaccess correctly.

After clearing the Chrome browser cache those merged files were compressed too, according to PageSpeed Insights. I guess some old uncompressed files were served from the browser cache...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.