Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've configured my site to serve compressed content by putting this line in .htaccess

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/javascript application/json

This works perfectly for almost all files except a few large JSON files that are above 200Kb. For some reason they are not being compressed. I see that they don't using the net tab in firebug and the Network section in chrome.

So as a workaround I thought I could compress these files offline and have Apache read them compressed.
What tool should I use to compress them? is the linux gzip the one? any special flags or something I should use?
What should I put in .htaccess so that the server would know to serve these files with content-encoding gzip ?

share|improve this question

Yes, use gzip to compress the file. You'll save a little of CPU power.

gzip -c your_big_json_file > your_big_json_file.gz

Then in your Apache configuration enable Multiviews

Options MultiViews

it does content-negotiation with the browser.

Note: change the reference to your json file in the code to use the newly created .gz file!

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.