Skip to content
This repository was archived by the owner on Sep 23, 2022. It is now read-only.

Commit 2266e49

Browse files
committed
Add some htaccess tricks to optimize request
Signed-off-by: Stéphane HULARD <[email protected]>
1 parent d1087f8 commit 2266e49

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

config/samples/SAMPLE.htaccess

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,77 @@
2121
RewriteCond %{REQUEST_FILENAME} !-d
2222
RewriteRule ^(.*)$ /wp-cms/$1 [L]
2323
</IfModule>
24+
25+
########################### MOD_DEFLATE COMPRESSION ############################
26+
<IfModule mod_deflate.c>
27+
SetOutputFilter DEFLATE
28+
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/x-httpd-php
29+
</IfModule>
30+
31+
#For incompatible browsers
32+
BrowserMatch ^Mozilla/4 gzip-only-text/html
33+
BrowserMatch ^Mozilla/4\.0[678] no-gzip
34+
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
35+
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
36+
37+
#Do not put in cache if files are already in
38+
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|swf)$ no-gzip
39+
40+
################################ EXPIRE HEADERS ################################
41+
<IfModule mod_expires.c>
42+
ExpiresActive On
43+
ExpiresDefault "access plus 7200 seconds"
44+
ExpiresByType image/jpg "access plus 2592000 seconds"
45+
ExpiresByType image/jpeg "access plus 2592000 seconds"
46+
ExpiresByType image/png "access plus 2592000 seconds"
47+
ExpiresByType image/gif "access plus 2592000 seconds"
48+
49+
AddType image/x-icon .ico
50+
ExpiresByType image/ico "access plus 2592000 seconds"
51+
ExpiresByType image/icon "access plus 2592000 seconds"
52+
ExpiresByType image/x-icon "access plus 2592000 seconds"
53+
ExpiresByType text/css "access plus 2592000 seconds"
54+
ExpiresByType text/javascript "access plus 2592000 seconds"
55+
ExpiresByType text/html "access plus 7200 seconds"
56+
ExpiresByType application/xhtml+xml "access plus 7200 seconds"
57+
ExpiresByType application/javascript A259200
58+
ExpiresByType application/x-javascript "access plus 2592000 seconds"
59+
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
60+
</IfModule>
61+
62+
############################ CACHE CONTROL HEADERS #############################
63+
<IfModule mod_headers.c>
64+
#les proxies doivent donner le bon contenu
65+
Header append Vary User-Agent env=!dont-vary
66+
67+
<FilesMatch "\\.(ico|jpe?g|png|gif|swf|gz|ttf)$">
68+
Header set Cache-Control "max-age=2592000, public"
69+
</FilesMatch>
70+
<FilesMatch "\\.(css)$">
71+
Header set Cache-Control "max-age=2592000, public"
72+
</FilesMatch>
73+
<FilesMatch "\\.(js)$">
74+
Header set Cache-Control "max-age=2592000, private"
75+
</FilesMatch>
76+
<FilesMatch "\\.(html|htm)$">
77+
Header set Cache-Control "max-age=7200, public"
78+
</FilesMatch>
79+
80+
# Disable caching for scripts and other dynamic files
81+
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
82+
Header unset Cache-Control
83+
</FilesMatch>
84+
85+
# KILL THEM ETAGS
86+
Header unset ETag
87+
FileETag none
88+
</IfModule>
89+
90+
############################ PROTECT HTACCESS FILE #############################
91+
<Files .htaccess>
92+
Order allow,deny
93+
Deny from all
94+
</Files>
95+
96+
############################ PROTECT FOLDER LISTING ############################
97+
Options -Indexes

0 commit comments

Comments
 (0)