summaryrefslogtreecommitdiff
path: root/apache2/conf-available/local-html5.conf
blob: 204473e177e7a561a094e665bb19ac1de4d7f5c7 (plain)
  1. # Apache configuration file
  2. # httpd.apache.org/docs/2.2/mod/quickreference.html
  3. # Note .htaccess files are an overhead, this logic should be in your Apache config if possible
  4. # httpd.apache.org/docs/2.2/howto/htaccess.html
  5. # Techniques in here adapted from all over, including:
  6. # Kroc Camen: camendesign.com/.htaccess
  7. # perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
  8. # Sample .htaccess file of CMS MODx: modxcms.com
  9. ###
  10. ### If you run a webserver other than Apache, consider:
  11. ### github.com/paulirish/html5-boilerplate-server-configs
  12. ###
  13. # ----------------------------------------------------------------------
  14. # Better website experience for IE users
  15. # ----------------------------------------------------------------------
  16. # Force the latest IE version, in various cases when it may fall back to IE7 mode
  17. # github.com/rails/rails/commit/123eb25#commitcomment-118920
  18. # Use ChromeFrame if it's installed for a better experience for the poor IE folk
  19. <IfModule mod_headers.c>
  20. Header set X-UA-Compatible "IE=Edge,chrome=1"
  21. # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
  22. <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
  23. Header unset X-UA-Compatible
  24. </FilesMatch>
  25. </IfModule>
  26. # ----------------------------------------------------------------------
  27. # Proper MIME type for all files
  28. # ----------------------------------------------------------------------
  29. # JavaScript
  30. # Normalize to standard type (it's sniffed in IE anyways)
  31. # tools.ietf.org/html/rfc4329#section-7.2
  32. AddType application/javascript js
  33. # Audio
  34. AddType audio/ogg oga ogg
  35. AddType audio/mp4 m4a
  36. # Video
  37. AddType video/ogg ogv
  38. AddType video/mp4 mp4 m4v
  39. AddType video/webm webm
  40. # SVG.
  41. # Required for svg webfonts on iPad
  42. # twitter.com/FontSquirrel/status/14855840545
  43. AddType image/svg+xml svg svgz
  44. AddEncoding gzip svgz
  45. # Webfonts
  46. AddType application/vnd.ms-fontobject eot
  47. AddType application/x-font-ttf ttf ttc
  48. AddType font/opentype otf
  49. AddType application/x-font-woff woff
  50. # Assorted types
  51. AddType image/x-icon ico
  52. AddType image/webp webp
  53. AddType text/cache-manifest appcache manifest
  54. AddType text/x-component htc
  55. AddType application/x-chrome-extension crx
  56. AddType application/x-xpinstall xpi
  57. AddType application/octet-stream safariextz
  58. AddType text/x-vcard vcf
  59. # ----------------------------------------------------------------------
  60. # Gzip compression
  61. # ----------------------------------------------------------------------
  62. <IfModule mod_deflate.c>
  63. # Force deflate for mangled headers 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. # HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
  71. <IfModule filter_module>
  72. FilterDeclare COMPRESS
  73. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
  74. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
  75. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain
  76. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml
  77. FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component
  78. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript
  79. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json
  80. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml
  81. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml
  82. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml
  83. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml
  84. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject
  85. FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml
  86. FilterProvider COMPRESS DEFLATE resp=Content-Type $image/x-icon
  87. FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf
  88. FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype
  89. FilterChain COMPRESS
  90. FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
  91. </IfModule>
  92. <IfModule !mod_filter.c>
  93. # Legacy versions of Apache
  94. AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
  95. AddOutputFilterByType DEFLATE application/javascript
  96. AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
  97. AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
  98. AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
  99. </IfModule>
  100. </IfModule>
  101. # ----------------------------------------------------------------------
  102. # Expires headers (for better cache control)
  103. # ----------------------------------------------------------------------
  104. # These are pretty far-future expires headers.
  105. # They assume you control versioning with cachebusting query params like
  106. # <script src="application.js?20100608">
  107. # Additionally, consider that outdated proxies may miscache
  108. # www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/
  109. # If you don't use filenames to version, lower the CSS and JS to something like
  110. # "access plus 1 week" or so.
  111. <IfModule mod_expires.c>
  112. ExpiresActive on
  113. # Perhaps better to whitelist expires rules? Perhaps.
  114. ExpiresDefault "access plus 1 month"
  115. # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
  116. ExpiresByType text/cache-manifest "access plus 0 seconds"
  117. # Your document html
  118. ExpiresByType text/html "access plus 0 seconds"
  119. # Data
  120. ExpiresByType text/xml "access plus 0 seconds"
  121. ExpiresByType application/xml "access plus 0 seconds"
  122. ExpiresByType application/json "access plus 0 seconds"
  123. # Feed
  124. ExpiresByType application/rss+xml "access plus 1 hour"
  125. ExpiresByType application/atom+xml "access plus 1 hour"
  126. # Favicon (cannot be renamed)
  127. ExpiresByType image/x-icon "access plus 1 week"
  128. # Media: images, video, audio
  129. ExpiresByType image/gif "access plus 1 month"
  130. ExpiresByType image/png "access plus 1 month"
  131. ExpiresByType image/jpg "access plus 1 month"
  132. ExpiresByType image/jpeg "access plus 1 month"
  133. ExpiresByType video/ogg "access plus 1 month"
  134. ExpiresByType audio/ogg "access plus 1 month"
  135. ExpiresByType video/mp4 "access plus 1 month"
  136. ExpiresByType video/webm "access plus 1 month"
  137. # HTC files (css3pie)
  138. ExpiresByType text/x-component "access plus 1 month"
  139. # Webfonts
  140. ExpiresByType application/x-font-ttf "access plus 1 month"
  141. ExpiresByType font/opentype "access plus 1 month"
  142. ExpiresByType application/x-font-woff "access plus 1 month"
  143. ExpiresByType image/svg+xml "access plus 1 month"
  144. ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  145. # CSS and JavaScript
  146. ExpiresByType text/css "access plus 1 year"
  147. ExpiresByType application/javascript "access plus 1 year"
  148. <IfModule mod_headers.c>
  149. Header append Cache-Control "public"
  150. </IfModule>
  151. </IfModule>
  152. # ----------------------------------------------------------------------
  153. # ETag removal
  154. # ----------------------------------------------------------------------
  155. # FileETag None is not enough for every server.
  156. <IfModule mod_headers.c>
  157. Header unset ETag
  158. </IfModule>
  159. # Since we're sending far-future expires, we don't need ETags for
  160. # static content.
  161. # developer.yahoo.com/performance/rules.html#etags
  162. FileETag None
  163. # ----------------------------------------------------------------------
  164. # Stop screen flicker in IE on CSS rollovers
  165. # ----------------------------------------------------------------------
  166. # The following directives stop screen flicker in IE on CSS rollovers - in
  167. # combination with the "ExpiresByType" rules for images (see above). If
  168. # needed, un-comment the following rules.
  169. # BrowserMatch "MSIE" brokenvary=1
  170. # BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
  171. # BrowserMatch "Opera" !brokenvary
  172. # SetEnvIf brokenvary 1 force-no-vary