Last active
December 26, 2015 00:38
-
-
Save fabioyamate/7065231 to your computer and use it in GitHub Desktop.
Apache2 assets config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a2enmod headers expires | |
SetEnv no-gzip | |
<LocationMatch "^/assets/.*\.(css|js)$"> | |
RewriteEngine on | |
# Make sure the browser supports gzip encoding before we send it, | |
# and that we have a precompiled .gz version. | |
RewriteCond %{HTTP:Accept-Encoding} \b(x-)?gzip\b | |
RewriteCond %{REQUEST_FILENAME}.gz -s | |
RewriteRule ^(.+)$ $1.gz | |
</LocationMatch> | |
<LocationMatch "^/assets/.*\.css\.gz$"> | |
ForceType text/css | |
Header set Content-Encoding gzip | |
Header add Vary Accept-Encoding | |
</LocationMatch> | |
<LocationMatch "^/assets/.*\.js\.gz$"> | |
ForceType application/javascript | |
Header set Content-Encoding gzip | |
Header add Vary Accept-Encoding | |
</LocationMatch> | |
# The Expires* directives requires the Apache module `mod_expires` to be enabled. | |
<Location /assets/> | |
# Use of ETag is discouraged when Last-Modified is present | |
Header unset ETag | |
FileETag None | |
# RFC says only cache for 1 year | |
ExpiresActive On | |
ExpiresDefault "access plus 1 year" | |
</Location> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment