FileEtag None
ErrorDocument 404 /404.html

### Apply a Cache-Control header to index.html
<IfModule mod_headers.c>
  <FilesMatch "\.css$">
    Header add Vary "Accept-Encoding"
  </FilesMatch>
  <FilesMatch "\.(html|png|jpeg|jpg|gif|flv|ico)$">
    #Header append Cache-Control "public, must-revalidate"
    #Header append Cache-Control "public, stale-while-revalidate"
    Header append Cache-Control "public"
  </FilesMatch>
</IfModule>

<IfModule mod_expires.c>
  ## activate mod_expires
  ExpiresActive On

# cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
  ExpiresByType text/cache-manifest       "access plus 0 seconds"

# your document html 
  #ExpiresByType text/html                 "access plus 60 seconds"
  ExpiresByType text/html                 "access plus 1 hour"
  
# data
  ExpiresByType text/xml                  "access plus 0 seconds"
  ExpiresByType application/xml           "access plus 0 seconds"
  ExpiresByType application/json          "access plus 0 seconds"

# rss feed
  ExpiresByType application/rss+xml       "access plus 1 hour"

# favicon (cannot be renamed)
  ExpiresByType image/x-icon              "access plus 1 week" 

  ### Expire .gif's 1 month from when they're accessed
# media: images, video, audio
  ExpiresByType image/gif                 "access plus 1 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpg                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"
  ExpiresByType video/ogg                 "access plus 1 month"
  ExpiresByType audio/ogg                 "access plus 1 month"
  ExpiresByType video/mp4                 "access plus 1 month"
  ExpiresByType video/webm                "access plus 1 month"

# css and javascript
  ExpiresByType text/css                  "access plus 2 months"
  ExpiresByType application/javascript    "access plus 2 months"
  ExpiresByType text/javascript           "access plus 2 months"
  ExpiresByType application/x-javascript  "modification plus 2 months"

  ### Expire everything else 1 month from when it's last modified
  ExpiresDefault "access plus 1 month"
</IfModule>

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript application/json 
  Header append Vary Accept-Encoding
</IfModule>

<IfModule mod_gzip.c>
mod_gzip_on Yes

mod_gzip_item_include mime ^application/x-javascript$
mod_gzip_item_include mime ^application/json$ 
mod_gzip_item_include mime ^text/.*$ 

mod_gzip_item_include file \.html$ 
mod_gzip_item_include file \.php$
mod_gzip_item_include file \.js$ 
mod_gzip_item_include file \.css$
mod_gzip_item_include file \.txt$ 
mod_gzip_item_include file \.xml$
mod_gzip_item_include file \.json$

Header append Vary Accept-Encoding
</IfModule>

#RewriteEngine on
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteOptions Inherit
  #RewriteLog "logs/rewrite.log"

  #RewriteCond %{HTTP_HOST} ^lence\.net [NC]
  #RewriteRule ^(.*) http://www.lence.net/$1 [R=301,L]
  RewriteCond %{HTTP_HOST}   !^www\.lence\.net [NC]
  RewriteCond %{HTTP_HOST}   !^$
  RewriteRule ^/(.*)         http://www.lence.net/$1 [L,R=301]

  #Check to see if browser can accept gzip files.
  ReWriteCond %{HTTP:accept-encoding} (gzip.*)

  #make sure there's no trailing .gz on the url
  ReWriteCond %{REQUEST_FILENAME} !^.+\.gz$
  
  #check to see if a .gz version of the file exists.
  RewriteCond %{REQUEST_FILENAME}.gz -f
  
  #All conditions met so add .gz to URL filename (invisibly)
  RewriteRule ^(.+) $1.gz [L]

</IfModule>
