Skip to content

Instantly share code, notes, and snippets.

@cristiroma
Created March 27, 2017 08:10
Show Gist options
  • Save cristiroma/b36c2c5dcff63988ffff0f02f2abf81d to your computer and use it in GitHub Desktop.
Save cristiroma/b36c2c5dcff63988ffff0f02f2abf81d to your computer and use it in GitHub Desktop.
.htaccess file for production
FileETag MTime Size
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access 1 month"
ExpiresByType text/html "access 1 month"
# CSS
ExpiresByType text/css "access 1 year"
ExpiresByType application/javascript "access 1 year"
ExpiresByType application/x-javascript "access 1 year"
ExpiresByType text/javascript "access 1 year"
# Data interchange
ExpiresByType application/atom+xml "access 1 hour"
ExpiresByType application/rdf+xml "access 1 hour"
ExpiresByType application/rss+xml "access 1 hour"
ExpiresByType application/json "access 0 seconds"
ExpiresByType application/ld+json "access 0 seconds"
ExpiresByType application/schema+json "access 0 seconds"
ExpiresByType application/vnd.geo+json "access 0 seconds"
ExpiresByType application/xml "access 0 seconds"
ExpiresByType text/xml "access 0 seconds"
ExpiresByType application/manifest+json "access 1 week"
ExpiresByType application/x-web-app-manifest+json "access 0 seconds"
ExpiresByType text/cache-manifest "access 0 seconds"
# Favicon and cursor images
ExpiresByType image/vnd.microsoft.icon "access 1 year"
ExpiresByType image/x-icon "access 1 year"
# Media files
ExpiresByType audio/ogg "access 1 year"
ExpiresByType image/bmp "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg+xml "access 1 year"
ExpiresByType image/webp "access 1 year"
ExpiresByType video/mp4 "access 1 year"
ExpiresByType video/ogg "access 6 months"
ExpiresByType video/webm "access 6 months"
</IfModule>
<FilesMatch "\.(woff2)$">
<IfModule !mod_headers.c>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access 1 year"
</IfModule>
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control "max-age=290304000, no-transform, public"
Header set Expires "Tue, 20 Jan 2037 04:20:42 GMT"
</IfModule>
</FilesMatch>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/rdf+xml" \
"application/rss+xml" \
"application/xhtml+xml" \
"application/xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"font/eot" \
"font/opentype" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vcard" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
<IfModule mod_mime.c>
AddType font/woff2 woff2
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment