Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Keep-Alive, early in .htaccess
- Header set Connection Keep-Alive
- Header set Keep-Alive "timeout=7, max=25"
- ## About halfway through .htaccess, these preliminary rules for proper Internet Media types (MIME types)
- <IfModule mod_mime.c>
- # Audio
- AddType audio/mp4 m4a f4a f4b
- AddType audio/ogg oga ogg
- # JavaScript
- # Normalize to standard type (it's sniffed in IE anyways):
- # http://tools.ietf.org/html/rfc4329#section-7.2
- AddType application/javascript js jsonp es
- AddType application/json json map
- AddType application/x-ns-proxy-autoconfig pac
- # Video
- AddType video/mp4 mp4 m4v f4v f4p
- AddType video/ogg ogv
- AddType video/webm webm
- AddType video/x-flv flv
- # Web fonts
- AddType application/font-woff woff
- AddType application/vnd.ms-fontobject eot
- # Browsers usually ignore the font MIME types and sniff the content,
- # however, Chrome shows a warning if other MIME types are used for the
- # following fonts.
- AddType application/x-font-ttf ttc ttf
- AddType font/opentype otf
- # Make SVGZ fonts work on iPad:
- # https://twitter.com/FontSquirrel/status/14855840545
- AddType image/svg+xml svg svgz
- AddEncoding gzip svgz
- # Other
- AddType application/octet-stream safariextz
- AddType application/x-chrome-extension crx
- AddType application/x-opera-extension oex
- AddType application/x-shockwave-flash swf
- AddType application/x-web-app-manifest+json webapp
- AddType application/x-xpinstall xpi
- AddType application/xml atom rdf rss xml
- AddType application/xhtml+xml xhtml xhtm xht
- AddType application/pdf pdf
- AddType image/bmp bmp
- AddType image/webp webp
- AddType image/x-icon ico
- AddType text/cache-manifest appcache manifest
- AddType text/vtt vtt
- AddType text/x-component htc
- AddType text/x-vcard vcf
- AddType text/plain txt
- AddType text/css css
- AddType text/html html htm shtml shtm sht
- AddHandler server-parsed .html
- AddHandler server-parsed .htm
- AddHandler server-parsed .shtml
- AddHandler server-parsed .shtm
- AddHandler server-parsed .sht
- </IfModule>
- ## Next, these rules for gzipping; comment out the <IfModule mod_filter.c> and following </IfModule> lines if your version of Apache doesn't have this module
- <IfModule mod_deflate.c>
- # Force compression for mangled headers.
- # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
- <IfModule mod_setenvif.c>
- <IfModule mod_headers.c>
- SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
- RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
- </IfModule>
- </IfModule>
- <Files ~ "^[^\.]+$">
- ForceType application/x-httpd-php
- SetOutputFilter DEFLATE
- </Files>
- # Compress all output labeled with one of the following MIME-types
- # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
- # and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
- # as `AddOutputFilterByType` is still in the core directives).
- <FilesMatch "\.(js|es|jsonp?|map|pac|css|html?|xhtml?|xht|shtml?|sht|txt|appcache|manifest|php|xml|ico|bmp|otf|ttf|svg|woff)$">
- SetOutputFilter DEFLATE
- </FilesMatch>
- <IfModule mod_filter.c>
- AddOutputFilterByType DEFLATE application/atom+xml application/javascript application/json application/rdf+xml application/rss+xml application/vnd.ms-fontobject application/x-font-otf \
- application/x-font-ttf application/x-javascript application/x-javascript-config application/x-ns-proxy-autoconfig application/x-web-app-manifest+json application/xhtml+xml \
- application/xml font/truetype font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/html text/javascript text/plain text/x-component text/xml
- </IfModule>
- # 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 \bMSIE !no-gzip !gzip-only-text/html
- # Don't compress images
- SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
- # Make sure proxies don't deliver the wrong content
- Header append Vary User-Agent env=!dont-vary
- </IfModule>
- ## If you decide to make WebP versions of your site images available as part of your build process, here's how to serve them to browsers that support them
- # Send WebP images to browsers that accept them
- RewriteCond %{HTTP_USER_AGENT} !(Chrome\/[0-8]|Android\s[0-3])\.
- RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
- RewriteCond %{HTTP_ACCEPT} \bimage/webp\b
- RewriteCond %{REQUEST_URI} (.+\.)(bmp|gif|jpe?g|png)$ [NC]
- RewriteCond %{DOCUMENT_ROOT}/$1webp -f
- RewriteRule (.+\.)(bmp|gif|jpe?g|png)$ $1webp [T=image/webp,E=accept:1]
- ## Later on in .htaccess, some rules about language
- AddDefaultCharset utf-8
- DefaultLanguage en-US
- AddLanguage en-US .html .htm .xhtml .xhtm .xht .shtml .shtm .sht .css .js .es .json .jsonp .map .pac wpad.dat .php
- ## Now some rules about cache-control and Expires headers
- # BEGIN Expires headers
- <IfModule mod_expires.c>
- ExpiresActive On
- ExpiresDefault "access plus 5 seconds"
- ExpiresByType image/x-icon "access plus 2592000 seconds"
- ExpiresByType image/jpeg "access plus 2592000 seconds"
- ExpiresByType image/png "access plus 2592000 seconds"
- ExpiresByType image/gif "access plus 2592000 seconds"
- ExpiresByType image/bmp "access plus 2592000 seconds"
- ExpiresByType image/webp "access plus 2592000 seconds"
- ExpiresByType application/pdf "access plus 2592000 seconds"
- ExpiresByType text/pdf "access plus 2592000 seconds"
- ExpiresByType application/vnd.pdf "access plus 2592000 seconds"
- ExpiresByType application/x-pdf "access plus 2592000 seconds"
- ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
- ExpiresByType text/css "access plus 604800 seconds"
- ExpiresByType text/javascript "access plus 604800 seconds"
- ExpiresByType application/javascript "access plus 604800 seconds"
- ExpiresByType application/x-javascript "access plus 604800 seconds"
- ExpiresByType application/x-javascript-config "access plus 604800 seconds"
- ExpiresByType application/x-ns-proxy-autoconfig "access plus 604800 seconds"
- ExpiresByType text/html "access plus 600 seconds"
- ExpiresByType application/xhtml+xml "access plus 600 seconds"
- ExpiresByType text/plain "access plus 600 seconds"
- </IfModule>
- # END Expires headers
- # BEGIN Cache-Control Headers
- <IfModule mod_headers.c>
- <FilesMatch "\.(x?html?|shtml?|xhtm?|shtm?|php)$">
- Header set Cache-Control "private, must-revalidate"
- </FilesMatch>
- <FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|bmp|webp|css|css\.php|swf)$">
- Header set Cache-Control "public"
- </FilesMatch>
- <FilesMatch "\.(js|js\.php|es|jsonp?|map|pac)$">
- Header set Cache-Control "private"
- </FilesMatch>
- </IfModule>
- # END Cache-Control Headers
- Now some rules about charsets
- <IfModule mod_mime.c>
- AddCharset iso-8859-1 .pac wpad.dat
- AddCharset utf-8 .appcache .atom .css .js .es .json .jsonp .map .rss .vtt .webapp .xml
- </IfModule>
- ## Finally, near the end, a rule about ETags (and a commented rule for turning ETags off)
- #FileETag none
- FileETag MTime Size
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement