.min.js does not redirect to .min.js.gz in some Apache configurations
| Project: | Javascript Aggregator |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
After installing and enabling the module I found that my browser (FF3.5+Firebug+PageSpeed) does not receive the JSmin+GZip version from the cache. Is this just me or is the module not working for anyone else either?
It seems the .htaccess file is set up for .js -> .gz files, but the code generates a cache of .jsmin.gz files so Apache won't find the GZip cache.
Also, the $footer output contains references to the .jsmin files which is just wrong as the .htaccess directives don't even look at that. In fact the .jsmin files should be removed as it's only an intermediate step and simply wastes disk space.
Fixed javascript_aggregator.module:
104-105;
if (!file_exists($aggregated_file .'.gz')) {
file_save_data(gzencode($contents, 9), $aggregated_file .'.gz', FILE_EXISTS_REPLACE);138:
//$scripts = str_replace($aggregated_file, $jsmin_file, $scripts);

#1
Turned this into an actual patch against DRUPAL-6--1 in CVS. Patch attached. Needs testing.
#2
You are gzipping the aggregated file and sending the aggregated.js.gz, not the aggregated and minified file which is better. Anyway, it's a server configuration problem, see http://drupal.org/node/290280#comment-1392934
On localhost, I had this problem with the module (and that's why I came here), but on the production server, the module works fine.
#3
#0 All your patch does is to bypass the JSMin minification. That makes no sense.
Check the screenshot. After enabling javascript_aggregator AND (!) clearing the browser cache (!) YSlow hands out a B on "compress components with gzip"
The css file is the only one which is not gzipped.
#4
@#0:
Like #3 said, do some more testing, clear site & browser caches, refresh... Didn't work for me first time around either but finally it did.
From reading the GZip CSS issues, my understanding is that the non gzipped version has to remain for browsers that don't support gzip. .htaccess is supposed to test and only rewrite for browsers that support it.
RewriteRule ^(.*)\.js $1.js.gz [L,QSA]Looks to me like any
*.jsfile is supposed to rewrite to*.js.gz. That includesxxx.jsmin.js. According to the GZip CSS project, on some servers you have to put the rules in the main .htaccess rather than in a per-directory .htaccess. Maybe your server is one of those. Try placing the rewrite rules in your main .htaccess.Servers also handle rewrite rules differently (at least for me, who may very well be writing crappy rewrite rules). Could be that the rule just doesn't work for your server.