0

我使用 mod_deflate 压缩我的 (html|css|js|xml|php|txt) 文件。(工作没有任何问题)

我还将我的 CSS / JS 脚本与 mod_include 模块结合起来以保存请求......两者都运行良好......但它们是未压缩的。

在我的组合 CSS 文件中,我使用了 Outputfilter DEFLATE,它与 Include MOD 一起使用,但在我的组合 JS 文件中它不起作用。

如果我使用它,Include Mod 不起作用,它会响应组合 JS 文件的原始包含内容:

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>

它输出 .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" -->

知道它是如何工作的,还是让我自己压缩每个文件?

4

1 回答 1

0

好的,我用这个 htaccess 找到了一个很好的解决方案:

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>
于 2018-02-23T10:26:45.047 回答