Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using mod_deflate to compress my .css and .js files on the fly:

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</ifmodule>

The problem is that this compresses the files on the fly, which takes some system resources when dealing with large files.

So I want to pre-compress my files so that they will be served directly to drop down server load. I want to store them with the other css and js files like style.css and style.gz then use php headers to check if the client accepts the gzip encoding to decide whether to serve the .css or the .gz file. FOR THE CHECK IT'S NOT THE PROBLEM. The problem is how to PRE-compress the files.

I came across some topics like this but none of them worked for me. It looks simple but it gave me a 500 Internal Server Error.

Is there any tool or whatever that does this job?

share|improve this question
    
What is the error in your apache error log? –  karmawhore Oct 15 '10 at 3:57
add comment

1 Answer

You could write a simple bash script:

#!/bin/bash
for file in *.css *.js; do
  gzip -c $file > $file.gz;
done
share|improve this answer
    
+1. It's the logical answer - so logical that I think that we may have misunderstood the question. –  lunchmeat317 Jan 18 '12 at 5:04
    
well, if @user57192 comes back and clarifies, i'll be sure to update my answer. –  Jayen Jan 18 '12 at 22:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.