# Compress static data
AddOutputFilterByType DEFLATE text/html text/plain text/javascript application/javascript text/css text/xml application/xml text/x-js application/x-javascript

# be sure to have those
AddType text/cache-manifest .appcache
AddType application/x-font-ttf .ttf
AddType application/x-font-woff .woff

# Define pre-compressed files
AddType text/javascript .jsz
AddType text/css .cssz .less
AddType text/xml .xmlz
AddEncoding gzip .jsz .cssz .xmlz
SetEnvIf Request_URI "\.(jsz|cssz|xmlz)$" no-gzip

# excluded PNGs
AddType image/png .xpng

ExpiresActive On
ExpiresDefault "access plus 6 months"
ExpiresByType image/ico "access plus 6 months"
ExpiresByType image/gif "access plus 6 months"
ExpiresByType image/png "access plus 6 months"
ExpiresByType image/jpg "access plus 6 months"
ExpiresByType image/jpeg "access plus 6 months"
ExpiresByType text/css "access plus 6 months"
ExpiresByType text/html "access plus 6 months"
ExpiresByType text/xml "access plus 6 months"
ExpiresByType text/javascript "access plus 6 months"
ExpiresByType application/x-javascript "access plus 6 months"
ExpiresByType text/cache-manifest "access plus 0 seconds"
ExpiresByType audio/mp3 "access plus 6 months"

# cache buster (exclude cache manifests and main pages)
<FilesMatch "^(?!(core|signin)).*$">
    # Modify headers
    Header append Cache-Control "private"
    Header unset Last-Modified
    Header unset Vary
    # Turn off ETag
    Header unset ETag
    FileETag None
</FilesMatch>

# do never ever cache
<FilesMatch "^(online\.js)$">
    ExpiresByType text/javascript "now"
    ExpiresByType application/x-javascript "now"
    ExpiresByType application/javascript "now"
    Header set Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
</FilesMatch>

<FilesMatch "^(core|signin)$">
    # must be done this way otherwise firefox does not put these files into application cache
    Header set Content-type "text/html"
    ForceType "text/html"
    ExpiresByType text/html "now"
</FilesMatch>

RewriteEngine On
RewriteRule v=[^\/]+/(.+) $1 [L]
RewriteRule ^$ core [L]
