|
| 1 | +--- |
| 2 | +layout: none |
| 3 | +permalink: .htaccess |
| 4 | +--- |
| 5 | +# Compress text files |
| 6 | +<IfModule mod_deflate.c> |
| 7 | + |
| 8 | + # Force compression for mangled headers. |
| 9 | + # https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html |
| 10 | + <IfModule mod_setenvif.c> |
| 11 | + <IfModule mod_headers.c> |
| 12 | + SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding |
| 13 | + RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding |
| 14 | + </IfModule> |
| 15 | + </IfModule> |
| 16 | + |
| 17 | + # Compress all output labeled with one of the following MIME-types |
| 18 | + # (for Apache versions below 2.3.7, you don't need to enable `mod_filter` |
| 19 | + # and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines |
| 20 | + # as `AddOutputFilterByType` is still in the core directives). |
| 21 | + <IfModule mod_filter.c> |
| 22 | + AddOutputFilterByType DEFLATE application/atom+xml \ |
| 23 | + application/javascript \ |
| 24 | + application/json \ |
| 25 | + application/rss+xml \ |
| 26 | + application/vnd.ms-fontobject \ |
| 27 | + application/x-font-ttf \ |
| 28 | + application/x-web-app-manifest+json \ |
| 29 | + application/xhtml+xml \ |
| 30 | + application/xml \ |
| 31 | + font/opentype \ |
| 32 | + image/svg+xml \ |
| 33 | + image/x-icon \ |
| 34 | + text/css \ |
| 35 | + text/html \ |
| 36 | + text/plain \ |
| 37 | + text/x-component \ |
| 38 | + text/xml |
| 39 | + </IfModule> |
| 40 | + |
| 41 | +</IfModule> |
| 42 | + |
| 43 | +# Browser caching |
| 44 | +<IfModule mod_expires.c> |
| 45 | + ExpiresActive on |
| 46 | + ExpiresDefault "access plus 1 month" |
| 47 | + |
| 48 | + # CSS |
| 49 | + ExpiresByType text/css "access plus 1 year" |
| 50 | + |
| 51 | + # Data interchange |
| 52 | + ExpiresByType application/json "access plus 0 seconds" |
| 53 | + ExpiresByType application/xml "access plus 0 seconds" |
| 54 | + ExpiresByType text/xml "access plus 0 seconds" |
| 55 | + |
| 56 | + # Favicon (cannot be renamed!) |
| 57 | + ExpiresByType image/x-icon "access plus 1 week" |
| 58 | + |
| 59 | + # HTML components (HTCs) |
| 60 | + ExpiresByType text/x-component "access plus 1 month" |
| 61 | + |
| 62 | + # HTML |
| 63 | + ExpiresByType text/html "access plus 0 seconds" |
| 64 | + |
| 65 | + # JavaScript |
| 66 | + ExpiresByType application/javascript "access plus 1 year" |
| 67 | + |
| 68 | + # Manifest files |
| 69 | + ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" |
| 70 | + ExpiresByType text/cache-manifest "access plus 0 seconds" |
| 71 | + |
| 72 | + # Media |
| 73 | + ExpiresByType audio/ogg "access plus 1 month" |
| 74 | + ExpiresByType image/gif "access plus 1 month" |
| 75 | + ExpiresByType image/jpeg "access plus 1 month" |
| 76 | + ExpiresByType image/png "access plus 1 month" |
| 77 | + ExpiresByType video/mp4 "access plus 1 month" |
| 78 | + ExpiresByType video/ogg "access plus 1 month" |
| 79 | + ExpiresByType video/webm "access plus 1 month" |
| 80 | + |
| 81 | + # Web feeds |
| 82 | + ExpiresByType application/atom+xml "access plus 1 hour" |
| 83 | + ExpiresByType application/rss+xml "access plus 1 hour" |
| 84 | + |
| 85 | + # Web fonts |
| 86 | + ExpiresByType application/font-woff2 "access plus 1 month" |
| 87 | + ExpiresByType application/font-woff "access plus 1 month" |
| 88 | + ExpiresByType application/vnd.ms-fontobject "access plus 1 month" |
| 89 | + ExpiresByType application/x-font-ttf "access plus 1 month" |
| 90 | + ExpiresByType font/opentype "access plus 1 month" |
| 91 | + ExpiresByType image/svg+xml "access plus 1 month" |
| 92 | +</IfModule> |
0 commit comments