Question

I have the following .htaccess file copied directly from html5boilerplate.com:

<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 shows only one file that isn't compressed and it's filename is testing.cache and it's content is a mix of html and css. I renamed the file to testing.html and the file got compressed just fine. I expected that the testing.cache file will get compressed too since it falls into the text/html group (this is a file I'm loading via ajax on page load). So, am wondering if I can something like:

<FilesMatch "\.(cache)$">
    someDirectiveToCache .cache file
</FilesMatch>

I've looked at mod_deflate for any matching directive but to no luck. Sure I could leave it as testing.html but am wondering how it could be done for testing.cache. Also, I presumed the FilesMatch can be used within the <IfModule mod_deflate.c> module, since it can be (tested and using it) used inside the <IfModule mod_expires.c> like this:

<FilesMatch "\.(cache)$">
    ExpiresDefault "access plus 1 hour"
</FilesMatch>

My Apache version (if important) is: 2.2.15.

Was it helpful?

Solution

I managed to get this working, quite easy in the end actually. I went through all the documentation to find the AddOutputFilter directive which is plain simple and actually works with extensions.

The AddOutputFilter directive syntax as stated in the docs for version 2.2 is:

AddOutputFilter filter[;filter...] extension [extension] ...

In my example after the AddOutputFilterByType directive I added:

AddOutputFilter DEFLATE cache

Hope this helps someone in the future.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top