Take the 2-minute tour ×

I need to set the no-gzip flag if a request is coming from the Mozilla browser and the content being requested uses the mime type application/pdf. This seems like it should be fairly trivial, but I'm having some trouble figuring out the proper way of expressing it.

I've got the browser check using the following:

BrowserMatch ^Mozilla moz

From what I understand, that statement will set the environment variable 'moz' to true if the browser is Mozilla. After this though, I'm having some trouble. Specifically, I can't seem to find a way to figure out the content-type that's going to be returned. From looking at a list of apache environment variables, HTTP_ACCEPT seemed related, but I can't find a reference to the proper syntax for checking. From tutorials that I read, I had assumed that something along the lines of:

%{HTTP_ACCEPT} application/pdf pdf

would set the 'pdf' variable to true, but the apache sever wouldn't start (giving the strong hint that that's not right at all). A coworker also mentioned that he'd thought a directive called mime exists, which allows you to check the content-type as:

mime application/pdf pdf

Similarly though, I couldn't get that to work either (and I can't find any reference to such a directive even existing). Could someone point out some good beginner resources that would give me a clue about how to perform these checks and reference variables properly? I've mostly been checking the apache documentation itself and some of their tutorials, but I must be missing something.

For reference, the documentation I've been looking at thus far:



Thanks in advance for any help.

share|improve this question
add comment

1 Answer

You're very close, the deflate documentation has a sample configuration that shows how to gzip specific files or how to exempt certain files:


Place the BrowserMatch rules in a FilesMatch to make them only apply to PDFs.


That should work, good luck!


After some more information from the question poster it seems that mod_filter should be able to combine conditions for User-Agent (Browser) and Content-Type. (discussion in comments)

share|improve this answer
Thanks for the quick response. The only problem is that the pdf URL does not contain the .pdf extension. All the URLs in the system in question use the same baseline. The pdf itself is actually stored as a blob in an Oracle database, and is appended directly to the page whenever appropriate. Is there a way to use BrowserMatch in the same way as FilesMatch? Essentially, to only add the AdOutputFilterByType directive when the browser is Mozilla? –  BGT Feb 22 '11 at 13:57
Oh i see, tricky. After looking around it seems you might be able to user mod_filter to combine conditions for User-Agent (Browser) and Content-Type, but the documentation isn't very good there. Id try posting a question on that topic to serverfault perhaps. (updated answer to contain this information) –  ctcherry Feb 22 '11 at 18:02
add comment

Your Answer


