-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.htaccess.production
65 lines (57 loc) · 2.29 KB
/
.htaccess.production
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Enable WebP Switheroo
# Source: https://www.keycdn.com/blog/convert-to-webp-the-successor-of-jpeg/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule ^(assets/images.+)\.(jpe?g|png)$ $1.webp [T=image/webp,E=accept:1]
</IfModule>
<IfModule mod_headers.c>
Header append Vary Accept env=REDIRECT_accept
</IfModule>
AddType image/webp .webp
# Enable GZIP
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript image/svg+xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
# Expires Headers - 2678400s = 31 days
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 7200 seconds"
ExpiresByType image/gif "access plus 2678400 seconds"
ExpiresByType image/jpeg "access plus 2678400 seconds"
ExpiresByType image/png "access plus 2678400 seconds"
ExpiresByType image/svg+xml "access plus 2678400 seconds"
ExpiresByType text/css "access plus 518400 seconds"
ExpiresByType font/collection "access plus 2678400 seconds"
ExpiresByType font/otf "access plus 2678400 seconds"
ExpiresByType font/sfnt "access plus 2678400 seconds"
ExpiresByType font/ttf "access plus 2678400 seconds"
ExpiresByType font/woff "access plus 2678400 seconds"
ExpiresByType font/woff2 "access plus 2678400 seconds"
ExpiresByType text/javascript "access plus 2678400 seconds"
ExpiresByType application/x-javascript "access plus 2678400 seconds"
</IfModule>
# Cache Headers
<IfModule mod_headers.c>
# Cache specified files for 31 days
<FilesMatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf|svg|otf|eot|ttf|woff|woff2)$">
Header set Cache-Control "max-age=2678400, public"
</FilesMatch>
# Cache HTML files for a couple hours
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=7200, private, must-revalidate"
</FilesMatch>
# Cache PDFs for a day
<FilesMatch "\.(pdf)$">
Header set Cache-Control "max-age=86400, public"
</FilesMatch>
# Cache Javascripts for 31 days
<FilesMatch "\.(js)$">
Header set Cache-Control "max-age=2678400, private"
</FilesMatch>
</IfModule>