Created
June 15, 2019 21:00
-
-
Save seanpianka/20f727911fe2cf3072967ab99c80d322 to your computer and use it in GitHub Desktop.
apache compression, https forward, cache expiration/cache control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
"/etc/httpd/conf.d/ssl_rewrite.conf": | |
mode: "000644" | |
owner: root | |
group: root | |
content: | | |
RewriteEngine On | |
<If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'"> | |
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L] | |
</If> | |
# mod_deflate configuration | |
<IfModule mod_deflate.c> | |
# Restrict compression to these MIME types | |
AddOutputFilterByType DEFLATE text/plain | |
AddOutputFilterByType DEFLATE text/html | |
AddOutputFilterByType DEFLATE application/xhtml+xml | |
AddOutputFilterByType DEFLATE text/xml | |
AddOutputFilterByType DEFLATE application/xml | |
AddOutputFilterByType DEFLATE application/xml+rss | |
AddOutputFilterByType DEFLATE application/x-javascript | |
AddOutputFilterByType DEFLATE text/javascript | |
AddOutputFilterByType DEFLATE text/css | |
AddOutputFilterByType DEFLATE image/png | |
AddOutputFilterByType DEFLATE image/gif | |
AddOutputFilterByType DEFLATE image/jpeg | |
AddOutputFilterByType DEFLATE video/mp4 | |
# Level of compression (Highest 9 - Lowest 1) | |
DeflateCompressionLevel 9 | |
# Netscape 4.x has some problems. | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
# Netscape 4.06-4.08 have some more problems | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
# MSIE masquerades as Netscape, but it is fine | |
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html | |
<IfModule mod_headers.c> | |
# Make sure proxies don't deliver the wrong content | |
Header append Vary User-Agent env=!dont-vary | |
</IfModule> | |
</IfModule> | |
# Expire headers | |
<ifModule mod_expires.c> | |
ExpiresActive On | |
ExpiresByType image/jpeg "access plus 1 week" | |
ExpiresByType image/png "access plus 1 week" | |
ExpiresByType image/gif "access plus 1 week" | |
ExpiresByType video/mp4 "access plus 1 week" | |
ExpiresByType text/css "access plus 1 week" | |
ExpiresByType text/javascript "access plus 1 week" | |
ExpiresByType application/javascript "access plus 1 week" | |
</ifModule> | |
# Cache-Control Headers | |
<ifModule mod_headers.c> | |
<filesMatch "\.(ico|jpe?g|png|gif)$"> | |
Header set Cache-Control "max-age=604800, public" | |
</filesMatch> | |
<filesMatch "\.(css|js)$"> | |
Header set Cache-Control "max-age=604800, public" | |
</filesMatch> | |
</ifModule> | |
# END Cache-Control Headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment