logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Apache mod_deflate specific file extensions only
Author
XenonKilla



Joined: 06 Apr 2012
Posts: 8

PostPosted: Sun 24 Jan '16 1:52    Post subject: Apache mod_deflate specific file extensions only Reply with quote

I'm trying to enable mod_deflate on my server but I want to enable it for specific file extensions only. I keep seeing all kinds of ways to enable deflate using MIME types etc, but I'm looking for a way to do it by file extension. i.e. .js, .css, .html, .php

I came across this somewhere but I'm unable to verify if it's correct or not.

<IfModule mod_deflate.c>
<filesMatch "\.(js|css|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>

Can anyone verify or perhaps give me a better solution?

I'm running Apache 2.4.18 on Windows Server 2012 R2
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Mon 25 Jan '16 16:35    Post subject: Reply with quote

Is the deflate module loaded?

Try on the command line

Code:
httpd.exe -M
Back to top
XenonKilla



Joined: 06 Apr 2012
Posts: 8

PostPosted: Tue 26 Jan '16 7:36    Post subject: Reply with quote

I think you misunderstood my question, I know how to enable the deflate module, what I'm fuzzy on is whether or not this is the CORRECT way to enable deflate for specific file extensions. The module is enabled and so far the syntax I posted appears to be working correctly, I just want to make sure that this is the most correct and efficient way to go about doing this.
Back to top
jraute



Joined: 13 Sep 2013
Posts: 188
Location: Rheinland, Germany

PostPosted: Tue 26 Jan '16 10:00    Post subject: Reply with quote

Looks good.

The only alternative would be to use
Code:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain text/html text/xml
    AddOutputFilterByType DEFLATE text/css text/javascript
    AddOutputFilterByType DEFLATE application/xml application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript application/x-javascript
</IfModule>
Back to top
mmarino



Joined: 08 Jun 2018
Posts: 4
Location: USA, Cleveland

PostPosted: Fri 08 Jun '18 19:22    Post subject: deflate non-standard file extensions Reply with quote

I am using Apache 2.4.2 on Windows Server 2012 R2 and I am new to Apache.
I trying to configure Apache to use mod_deflate to compress specific, non-standard file extensions (mnt & rep). In your forum I found an example syntax as follows:
<IfModule mod_deflate.c>
<filesMatch "\.(js|css|html|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>

I replaced (js|css|html|php) with (mnt|rep), but I'm not seeing any difference in how long my test files are taking to download. I don't see anything in the logs that shows whether or not compression is actually active during the download. Is my syntax correct and are there logs, other than the error & access logs to review?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Mon 11 Jun '18 9:41    Post subject: Reply with quote

What are those files? Text based? binary? Does apache know the content type?
Back to top
mmarino



Joined: 08 Jun 2018
Posts: 4
Location: USA, Cleveland

PostPosted: Mon 11 Jun '18 13:49    Post subject: Reply with quote

They are text based and included a combination of pipe delimited data and some sql commands, but all text based.

When you say does apache know the content type, are you saying I should possibly use these commands instead?
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/mnt text/rep
</IfModule>
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Wed 13 Jun '18 11:32    Post subject: Reply with quote

Maybe you also have to add your files to conf/mime.types so apache knows thats these are text based files.
Back to top
mmarino



Joined: 08 Jun 2018
Posts: 4
Location: USA, Cleveland

PostPosted: Wed 13 Jun '18 15:35    Post subject: Reply with quote

I am not having an issue downloading the files, just compressing the files. Do you think a mime.types change would still be needed? I don't have Internet Information Services (IIS) Manager on my Windows server, which is what is recommended to add mime.types. Can the mime.types file be edited manually, if I stop and start the Apache service?

I did not get confirmation on whether the changes I made to the httpd.conf seem correct or if there are additional changes I should try.

Does the mod_deflate compression work for any Apache downloading or is it for website downloading only?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Wed 13 Jun '18 16:07    Post subject: Reply with quote

mmarino wrote:
Can the mime.types file be edited manually, if I stop and start the Apache service?

You can edit the file while apache is running and then restart apache. No need to stop it.


mmarino wrote:

Does the mod_deflate compression work for any Apache downloading or is it for website downloading only?


Apache can compress any file that is send to the server. For the server there is no difference if you view a file in a browser or "download it". For the server every request is sending data to the client.
mod_deflate can compress the data stream of most files before sending it to the client. mod_deflate uses zlib to do so. Often binary files can compressed aby further. That is why I asked if your files are text based Wink
Back to top
mmarino



Joined: 08 Jun 2018
Posts: 4
Location: USA, Cleveland

PostPosted: Wed 13 Jun '18 16:26    Post subject: Reply with quote

Tried to edit the mime.types file, but it says it is being used by another program, whether I stop or don't stop Apache. If the files are downloading, but just not compressing, do you still think they might need added to the mime.types?
Back to top


Reply to topic   Topic: Apache mod_deflate specific file extensions only View previous topic :: View next topic
Post new topic   Forum Index -> Apache