-
Notifications
You must be signed in to change notification settings - Fork 1
/
.htaccess
37 lines (35 loc) · 1.05 KB
/
.htaccess
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
<IfModule mod_headers.c>
<FilesMatch "\.(htm|html|js|css|xml|gz|jpg|png|json)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
<files *.js.gz>
AddType "text/javascript" .gz
AddEncoding gzip .gz
</files>
<files *.css.gz>
AddType "text/css" .gz
AddEncoding gzip .gz
</files>
RewriteEngine on
#Check to see if browser can accept gzip files.
ReWriteCond %{HTTP:accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
#make sure there's no trailing .gz on the url
ReWriteCond %{REQUEST_FILENAME} !^.+\.gz$
#check to see if a .gz version of the file exists.
RewriteCond %{REQUEST_FILENAME}.gz -f
#All conditions met so add .gz to URL filename (invisibly)
RewriteRule ^(.+) $1.gz [QSA,L]
# 480 weeks
<FilesMatch "\.(ico|pdf|png|gif|js|css|jpg|gz)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>
# 2 DAYS
<FilesMatch "\.(json)$">
Header set Cache-Control "max-age=172800, public, must-revalidate"
</FilesMatch>
# 2 HOURS
<FilesMatch "\.(htm|html)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>