html5boilerplate.comから直接コピーした次の.htaccess
ファイルがあります。
<IfModule mod_deflate.c>
# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
YSlowは、圧縮されていないファイルを 1 つだけ表示します。そのファイル名はtesting.cache
で、コンテンツは html と css が混在しています。ファイルの名前を に変更するtesting.html
と、ファイルは問題なく圧縮されました。testing.cache
ファイルはグループに分類されるため、ファイルも圧縮されると予想していましたtext/html
(これは、ページの読み込み時に ajax を介して読み込んでいるファイルです)。だから、私は次のようなことができるかどうか疑問に思っています:
<FilesMatch "\.(cache)$">
someDirectiveToCache .cache file
</FilesMatch>
一致するディレクティブについてmod_deflateを調べましたが、うまくいきませんでした。確かにそのままにしておくこともtesting.html
できますが、どうすればtesting.cache
. また、次のように(テストして使用して)内部で使用できるためFilesMatch
、モジュール内で使用できると推測しました。<IfModule mod_deflate.c>
<IfModule mod_expires.c>
<FilesMatch "\.(cache)$">
ExpiresDefault "access plus 1 hour"
</FilesMatch>
私の Apache のバージョン (重要な場合) は2.2.15です。