Skip to content

Instantly share code, notes, and snippets.

@carlowens
Created October 24, 2016 11:12
Show Gist options
  • Save carlowens/ce29010cd69494a5bf5c061857cd0a88 to your computer and use it in GitHub Desktop.
Save carlowens/ce29010cd69494a5bf5c061857cd0a88 to your computer and use it in GitHub Desktop.
apache 2.4 add expires headers and compression
a2enmod expires
-----------------
ExpiresActive on
# send an Expires: header for each of these mimetypes (as defined by server)
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
# css may change a bit sometimes, so define shorter expiration
ExpiresByType text/css "access plus 1 days"
ExpiresByType text/js "access plus 1 days"
ExpiresByType text/javascript "access plus 1 days"
ExpiresByType application/javascript "access plus 1 days"
ExpiresByType application/x-javascript "access plus 1 days"
AddType image/vnd.microsoft.icon .ico
# now we have icon MIME type, we can use it
# my favicon doesn't change much
ExpiresByType image/vnd.microsoft.icon "access plus 3 months"
--------------------
a2enmod deflate
--------------------
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
--------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment