2

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?

1
  • What is the error in your apache error log?
    – karmawhore
    Oct 15, 2010 at 3:57

1 Answer 1

4

You could write a simple bash script:

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

You must log in to answer this question.