Skip to content

Instantly share code, notes, and snippets.

@Vlasterx
Created September 30, 2016 12:21
Show Gist options
  • Save Vlasterx/e711517abab6a97e7a17959104856ffa to your computer and use it in GitHub Desktop.
Save Vlasterx/e711517abab6a97e7a17959104856ffa to your computer and use it in GitHub Desktop.
# 300 5 MIN
# 600 10 MIN
# 900 15 MIN
# 1800 30 MIN
# 2700 45 MIN
# 3600 1 HR
# 7200 2 HR
# 10800 3 HR
# 14400 4 HR
# 18000 5 HR
# 36000 10 HR
# 39600 11 HR
# 43200 12 HR
# 46800 13 HR
# 50400 14 HR
# 54000 15 HR
# 86400 1 DAY
# 172800 2 DAY
# 259200 3 DAY
# 345600 4 DAY
# 432000 5 DAY
# 518400 6 DAY
# 604800 1 WEEK
# 1209600 2 WEEK
# 1814400 3 WEEK
# 2419200 4 WEEK
# 4838400 2 MONTH
# 7257600 3 MONTH
# 9676800 4 MONTH
# 12096000 5 MONTH
# 14515200 6 MONTH
# 16934400 7 MONTH
# 19353600 8 MONTH
# 21772800 9 MONTH
# 24192000 10 MONTH
# 26611200 11 MONTH
# 29030400 12 MONTH
@Vlasterx
Copy link
Author

Vlasterx commented Oct 13, 2016

Apache cache times

<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresDefault "access plus 1 week"

  # HTML
  ExpiresByType text/html "access plus 0 seconds"

  # Data interchange
  ExpiresByType application/json "access plus 0 seconds"
  ExpiresByType application/xml "access plus 0 seconds"
  ExpiresByType text/xml "access plus 0 seconds"

  # CSS
  ExpiresByType text/css "access plus 1 month"

  # JavaScript
  ExpiresByType application/javascript "access plus 1 month"

  # Favicon (cannot be renamed!) and cursor images
  ExpiresByType image/x-icon "access plus 1 month"

  # Media
  ExpiresByType image/gif "access plus 1 week"
  ExpiresByType image/jpeg "access plus 1 week"
  ExpiresByType image/png "access plus 1 week"
  ExpiresByType audio/ogg "access plus 1 week"
  ExpiresByType video/mp4 "access plus 1 week"
  ExpiresByType video/ogg "access plus 1 week"
  ExpiresByType video/webm "access plus 1 week"
</IfModule>

<IfModule mod_headers.c>
  # no cache for data
  <FilesMatch "\.(json|xml)$">
      Header set Cache-Control "max-age=0"
  </FilesMatch>

  #1 month for scripts
  <FilesMatch "\.(js|css|hbs)$">
      Header set Cache-Control "max-age=2419200"
  </FilesMatch>

  #1 week for media files
  <FilesMatch "\.(jpg|jpeg|png|gif|swf|svg|mp4|ogg|webm)$">
      Header set Cache-Control "max-age=604800, public"
  </FilesMatch>

  # One week for fonts
  <FilesMatch "\.(woff|woff2|ttf|eot)$">
      Header set Cache-Control "max-age=604800, public"
  </FilesMatch>
</IfModule>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment