--- javascript_aggregator.module
+++ javascript_aggregator.module
@@ -101,8 +101,8 @@
       if (variable_get('javascript_aggregator_gzip', FALSE)) {
 
         // Create the GZip file if it doesn't already exist.
-        if (!file_exists($jsmin_file .'.gz')) {
-          file_save_data(gzencode($contents, 9), $jsmin_file .'.gz', FILE_EXISTS_REPLACE);
+        if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $path . $jsmin_file .'.gz')) {
+          file_save_data(gzencode($contents, 9), $_SERVER['DOCUMENT_ROOT'] . $path . $jsmin_file .'.gz', FILE_EXISTS_REPLACE);
         }
 
         // Make sure the .htaccess file is active to handle GZipped JavaScript files.
