Tom
Tom

Reputation: 161

htaccess mod_deflate and mod_include with JS files

i using mod_deflate to compress my (html|css|js|xml|php|txt) Files. (working without any problems)

I also combine my CSS / JS Scripts with the mod_include module to save requests... Both working well...but they are uncompressed.

With my combined CSS file i use the Outputfilter DEFLATE and it worked together with the Include MOD but with my combined JS File it did not work.

If i use it the Include Mod did not work it response the original include content of the combined JS file:

HTACCESS

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

 <IfModule mod_include.c>
    <FilesMatch "\.combined\.js$">
        Options +Includes
        AddOutputFilterByType INCLUDES application/javascript application/json
        SetOutputFilter INCLUDES
        SetOutputFilter DEFLATE
    </FilesMatch>
    <FilesMatch "\.combined\.css$">
        Options +Includes
        AddOutputFilterByType INCLUDES text/css
        SetOutputFilter INCLUDES
        SetOutputFilter DEFLATE
    </FilesMatch>
 </IfModule>

It outputs .combined.js:

<!--#include file="cloudzoom/cloud-zoom.1.0.2.min.js" -->

<!--#include file="supersized/supersized.3.2.7.min.js" -->
<!--#include file="supersized/supersized.shutter.min.js" -->

Any idea how it could be working or have i compress every single file by myself?

Upvotes: 0

Views: 747

Answers (1)

Tom
Tom

Reputation: 161

Ok i found a good solution with this htaccess it worked:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript


 <IfModule mod_include.c>
    <FilesMatch "\.combined\.js$">
        Options +Includes
        AddOutputFilterByType INCLUDES application/javascript application/json
        SetOutputFilter INCLUDES
    </FilesMatch>
    <FilesMatch "\.combined\.css$">
        Options +Includes
        AddOutputFilterByType INCLUDES text/css
        SetOutputFilter INCLUDES
    </FilesMatch>
 </IfModule>

Upvotes: 0

Related Questions