Advertisement
lewisje

some helpful .htaccess rules for speeding up buttcoin.org

May 23rd, 2014
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.55 KB | None | 0 0
  1. ## Keep-Alive, early in .htaccess
  2. Header set Connection Keep-Alive
  3. Header set Keep-Alive "timeout=7, max=25"
  4.  
  5. ## About halfway through .htaccess, these preliminary rules for proper Internet Media types (MIME types)
  6. <IfModule mod_mime.c>
  7. # Audio
  8. AddType audio/mp4 m4a f4a f4b
  9. AddType audio/ogg oga ogg
  10. # JavaScript
  11. # Normalize to standard type (it's sniffed in IE anyways):
  12. # http://tools.ietf.org/html/rfc4329#section-7.2
  13. AddType application/javascript js jsonp es
  14. AddType application/json json map
  15. AddType application/x-ns-proxy-autoconfig pac
  16. # Video
  17. AddType video/mp4 mp4 m4v f4v f4p
  18. AddType video/ogg ogv
  19. AddType video/webm webm
  20. AddType video/x-flv flv
  21. # Web fonts
  22. AddType application/font-woff woff
  23. AddType application/vnd.ms-fontobject eot
  24. # Browsers usually ignore the font MIME types and sniff the content,
  25. # however, Chrome shows a warning if other MIME types are used for the
  26. # following fonts.
  27. AddType application/x-font-ttf ttc ttf
  28. AddType font/opentype otf
  29. # Make SVGZ fonts work on iPad:
  30. # https://twitter.com/FontSquirrel/status/14855840545
  31. AddType image/svg+xml svg svgz
  32. AddEncoding gzip svgz
  33. # Other
  34. AddType application/octet-stream safariextz
  35. AddType application/x-chrome-extension crx
  36. AddType application/x-opera-extension oex
  37. AddType application/x-shockwave-flash swf
  38. AddType application/x-web-app-manifest+json webapp
  39. AddType application/x-xpinstall xpi
  40. AddType application/xml atom rdf rss xml
  41. AddType application/xhtml+xml xhtml xhtm xht
  42. AddType application/pdf pdf
  43. AddType image/bmp bmp
  44. AddType image/webp webp
  45. AddType image/x-icon ico
  46. AddType text/cache-manifest appcache manifest
  47. AddType text/vtt vtt
  48. AddType text/x-component htc
  49. AddType text/x-vcard vcf
  50. AddType text/plain txt
  51. AddType text/css css
  52. AddType text/html html htm shtml shtm sht
  53. AddHandler server-parsed .html
  54. AddHandler server-parsed .htm
  55. AddHandler server-parsed .shtml
  56. AddHandler server-parsed .shtm
  57. AddHandler server-parsed .sht
  58. </IfModule>
  59.  
  60. ## 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
  61. <IfModule mod_deflate.c>
  62. # Force compression for mangled headers.
  63. # http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
  64. <IfModule mod_setenvif.c>
  65. <IfModule mod_headers.c>
  66. SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
  67. RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
  68. </IfModule>
  69. </IfModule>
  70. <Files ~ "^[^\.]+$">
  71. ForceType application/x-httpd-php
  72. SetOutputFilter DEFLATE
  73. </Files>
  74. # Compress all output labeled with one of the following MIME-types
  75. # (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
  76. # and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
  77. # as `AddOutputFilterByType` is still in the core directives).
  78. <FilesMatch "\.(js|es|jsonp?|map|pac|css|html?|xhtml?|xht|shtml?|sht|txt|appcache|manifest|php|xml|ico|bmp|otf|ttf|svg|woff)$">
  79. SetOutputFilter DEFLATE
  80. </FilesMatch>
  81. <IfModule mod_filter.c>
  82. AddOutputFilterByType DEFLATE application/atom+xml application/javascript application/json application/rdf+xml application/rss+xml application/vnd.ms-fontobject application/x-font-otf \
  83. 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 \
  84. 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
  85. </IfModule>
  86. # Netscape 4.x has some problems...
  87. BrowserMatch ^Mozilla/4 gzip-only-text/html
  88. # Netscape 4.06-4.08 have some more problems
  89. BrowserMatch ^Mozilla/4\.0[678] no-gzip
  90. # MSIE masquerades as Netscape, but it is fine
  91. BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  92. # Don't compress images
  93. SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
  94. # Make sure proxies don't deliver the wrong content
  95. Header append Vary User-Agent env=!dont-vary
  96. </IfModule>
  97.  
  98. ## 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
  99. # Send WebP images to browsers that accept them
  100. RewriteCond %{HTTP_USER_AGENT} !(Chrome\/[0-8]|Android\s[0-3])\.
  101. RewriteCond %{HTTP_USER_AGENT} Chrome [OR]
  102. RewriteCond %{HTTP_ACCEPT} \bimage/webp\b
  103. RewriteCond %{REQUEST_URI} (.+\.)(bmp|gif|jpe?g|png)$ [NC]
  104. RewriteCond %{DOCUMENT_ROOT}/$1webp -f
  105. RewriteRule (.+\.)(bmp|gif|jpe?g|png)$ $1webp [T=image/webp,E=accept:1]
  106.  
  107. ## Later on in .htaccess, some rules about language
  108. AddDefaultCharset utf-8
  109. DefaultLanguage en-US
  110. AddLanguage en-US .html .htm .xhtml .xhtm .xht .shtml .shtm .sht .css .js .es .json .jsonp .map .pac wpad.dat .php
  111.  
  112. ## Now some rules about cache-control and Expires headers
  113. # BEGIN Expires headers
  114. <IfModule mod_expires.c>
  115. ExpiresActive On
  116. ExpiresDefault "access plus 5 seconds"
  117. ExpiresByType image/x-icon "access plus 2592000 seconds"
  118. ExpiresByType image/jpeg "access plus 2592000 seconds"
  119. ExpiresByType image/png "access plus 2592000 seconds"
  120. ExpiresByType image/gif "access plus 2592000 seconds"
  121. ExpiresByType image/bmp "access plus 2592000 seconds"
  122. ExpiresByType image/webp "access plus 2592000 seconds"
  123. ExpiresByType application/pdf "access plus 2592000 seconds"
  124. ExpiresByType text/pdf "access plus 2592000 seconds"
  125. ExpiresByType application/vnd.pdf "access plus 2592000 seconds"
  126. ExpiresByType application/x-pdf "access plus 2592000 seconds"
  127. ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
  128. ExpiresByType text/css "access plus 604800 seconds"
  129. ExpiresByType text/javascript "access plus 604800 seconds"
  130. ExpiresByType application/javascript "access plus 604800 seconds"
  131. ExpiresByType application/x-javascript "access plus 604800 seconds"
  132. ExpiresByType application/x-javascript-config "access plus 604800 seconds"
  133. ExpiresByType application/x-ns-proxy-autoconfig "access plus 604800 seconds"
  134. ExpiresByType text/html "access plus 600 seconds"
  135. ExpiresByType application/xhtml+xml "access plus 600 seconds"
  136. ExpiresByType text/plain "access plus 600 seconds"
  137. </IfModule>
  138. # END Expires headers
  139. # BEGIN Cache-Control Headers
  140. <IfModule mod_headers.c>
  141. <FilesMatch "\.(x?html?|shtml?|xhtm?|shtm?|php)$">
  142. Header set Cache-Control "private, must-revalidate"
  143. </FilesMatch>
  144. <FilesMatch "\.(ico|pdf|flv|jpe?g|png|gif|bmp|webp|css|css\.php|swf)$">
  145. Header set Cache-Control "public"
  146. </FilesMatch>
  147. <FilesMatch "\.(js|js\.php|es|jsonp?|map|pac)$">
  148. Header set Cache-Control "private"
  149. </FilesMatch>
  150. </IfModule>
  151. # END Cache-Control Headers
  152.  
  153. Now some rules about charsets
  154. <IfModule mod_mime.c>
  155. AddCharset iso-8859-1 .pac wpad.dat
  156. AddCharset utf-8 .appcache .atom .css .js .es .json .jsonp .map .rss .vtt .webapp .xml
  157. </IfModule>
  158.  
  159. ## Finally, near the end, a rule about ETags (and a commented rule for turning ETags off)
  160. #FileETag none
  161. FileETag MTime Size
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement