# -----------------------------------------------------------------------------
# ETags                                                              
# -----------------------------------------------------------------------------

<IfModule mod_headers.c>
    Header unset ETag
</IfModule>

# `FileETag None` doesn't work in all cases.
FileETag None

# -----------------------------------------------------------------------------
# Caching                                                            
# -----------------------------------------------------------------------------

<IfModule mod_expires.c>
	ExpiresActive On 
	ExpiresDefault "access plus 2 days"
	
	# CSS
	ExpiresByType text/css "access plus 1 week"
	
	# Favicon (cannot be renamed!) and cursor images
	ExpiresByType image/vnd.microsoft.icon "access plus 1 month"
	ExpiresByType image/x-icon "access plus 1 month"
	
	# Media files
	ExpiresByType audio/ogg "access plus 2 weeks"
	ExpiresByType image/bmp "access plus 2 weeks"
	ExpiresByType image/gif "access plus 2 weeks"
	ExpiresByType image/jpeg "access plus 2 weeks"
	ExpiresByType image/png "access plus 2 weeks"
	ExpiresByType image/svg+xml "access plus 2 weeks"
	ExpiresByType image/webp "access plus 2 weeks"
	ExpiresByType video/mp4 "access plus 2 weeks"
	ExpiresByType video/ogg "access plus 2 weeks"
	ExpiresByType video/webm "access plus 2 weeks"
		
	# Web fonts
	ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
	ExpiresByType font/eot "access plus 1 month"
	ExpiresByType font/opentype "access plus 1 month"
	ExpiresByType application/x-font-ttf "access plus 1 month"
	ExpiresByType application/font-woff "access plus 1 month"
	ExpiresByType application/x-font-woff "access plus 1 month"
	ExpiresByType font/woff "access plus 1 month"
	ExpiresByType application/font-woff2 "access plus 1 month"
	
	# JavaScript
	ExpiresByType application/javascript "access plus 1 week"
	ExpiresByType application/x-javascript "access plus 1 week"
	ExpiresByType text/javascript "access plus 1 week"
</IfModule>

# -----------------------------------------------------------------------------
# Compression                                                        
# -----------------------------------------------------------------------------

<IfModule mod_deflate.c>
    <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>

    <IfModule mod_filter.c>
        AddOutputFilterByType DEFLATE "application/atom+xml" \
                                      "application/javascript" \
                                      "application/json" \
                                      "application/ld+json" \
                                      "application/manifest+json" \
                                      "application/rdf+xml" \
                                      "application/rss+xml" \
                                      "application/schema+json" \
                                      "application/vnd.geo+json" \
                                      "application/vnd.ms-fontobject" \
                                      "application/x-font-ttf" \
                                      "application/x-javascript" \
                                      "application/x-web-app-manifest+json" \
                                      "application/xhtml+xml" \
                                      "application/xml" \
                                      "font/eot" \
                                      "font/opentype" \
                                      "image/bmp" \
                                      "image/svg+xml" \
                                      "image/vnd.microsoft.icon" \
                                      "image/x-icon" \
                                      "text/cache-manifest" \
                                      "text/css" \
                                      "text/html" \
                                      "text/javascript" \
                                      "text/plain" \
                                      "text/vcard" \
                                      "text/vnd.rim.location.xloc" \
                                      "text/vtt" \
                                      "text/x-component" \
                                      "text/x-cross-domain-policy" \
                                      "text/xml"
    </IfModule>

    <IfModule mod_mime.c>
        AddEncoding gzip svgz
    </IfModule>
</IfModule>

<Files  *.*>
  <IfModule mod_authz_core.c>
    # Apache 2.4
    <RequireAll>
      Require all granted
    </RequireAll>
  </IfModule>
  <IfModule !mod_authz_core.c>
    # Apache 2.2
    Order Allow,Deny
    Allow from all
  </IfModule>
</Files>