Created
February 8, 2019 05:38
-
-
Save mumairofficial/3d35b1010de803d7f297cbe731bd39ae to your computer and use it in GitHub Desktop.
For production distribution with text compression and other cache setting
This file contains 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
#REDIRECT ROUTES TO INDEX (fixes broken routes with angular) | |
RewriteEngine on | |
RewriteCond %{HTTP:X-Forwarded-Proto} !https | |
RewriteCond %{HTTPS} off | |
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] | |
RewriteCond %{REQUEST_FILENAME} -s [OR] | |
RewriteCond %{REQUEST_FILENAME} -l [OR] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^.*$ - [NC,L] | |
RewriteRule ^(.*) /index.html [NC,L] | |
#ENABLE GZIP COMPRESSION TO IMPROVE PERFORMANCE | |
AddOutputFilterByType DEFLATE text/plain | |
AddOutputFilterByType DEFLATE text/html | |
AddOutputFilterByType DEFLATE text/xml | |
AddOutputFilterByType DEFLATE text/css | |
AddOutputFilterByType DEFLATE application/xml | |
AddOutputFilterByType DEFLATE application/xhtml+xml | |
AddOutputFilterByType DEFLATE application/rss+xml | |
AddOutputFilterByType DEFLATE application/javascript | |
AddOutputFilterByType DEFLATE application/x-javascript | |
# SET EXPIRE HEADERS TO IMPROVE PERFORMANCE | |
<ifModule mod_expires.c> | |
ExpiresActive On | |
ExpiresDefault "access plus 2 days" | |
ExpiresByType image/x-icon "access plus 1 year" | |
ExpiresByType image/jpeg "access plus 1 year" | |
ExpiresByType image/jpg "access plus 1 year" | |
ExpiresByType image/png "access plus 1 year" | |
ExpiresByType image/gif "access plus 1 year" | |
ExpiresByType application/x-shockwave-flash "access plus 1 month" | |
ExpiresByType text/css "access plus 1 month" | |
ExpiresByType text/javascript "access plus 1 month" | |
ExpiresByType application/pdf "access plus 1 month" | |
ExpiresByType application/javascript "access plus 2 week" | |
ExpiresByType application/x-javascript "access plus 2 week" | |
ExpiresByType text/javascript "access plus 2 week" | |
ExpiresByType text/html "access plus 600 seconds" | |
ExpiresByType application/xhtml+xml "access plus 600 seconds" | |
</ifModule> | |
# END Expire headers | |
# BEGIN Cache-Control Headers | |
<ifModule mod_headers.c> | |
<filesMatch "\.(ico|jpe?g|png|gif|swf)$"> | |
Header set Cache-Control "public" | |
</filesMatch> | |
<filesMatch "\.(css)$"> | |
Header set Cache-Control "public" | |
</filesMatch> | |
<filesMatch "\.(js)$"> | |
Header set Cache-Control "public" | |
</filesMatch> | |
<filesMatch "\.(x?html?|php)$"> | |
Header set Cache-Control "private, must-revalidate" | |
</filesMatch> | |
</ifModule> | |
# END Cache-Control Headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment