Created
September 18, 2019 11:51
-
-
Save steelcm/e7f58ee721897f77aecc635b235cfb10 to your computer and use it in GitHub Desktop.
Enable expiration headers via .htaccess – Useful for WordPress and other sites
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
# Expiration Headers | |
<IfModule mod_expires.c> | |
FileETag MTime Size | |
AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript | |
ExpiresActive On | |
ExpiresByType text/html "access 600 seconds" | |
ExpiresByType application/xhtml+xml "access 600 seconds" | |
ExpiresByType text/css "access 1 month" | |
ExpiresByType text/javascript "access 1 month" | |
ExpiresByType text/x-javascript "access 1 month" | |
ExpiresByType application/javascript "access 1 month" | |
ExpiresByType application/x-javascript "access 1 month" | |
ExpiresByType application/x-shockwave-flash "access 1 month" | |
ExpiresByType application/pdf "access 1 month" | |
ExpiresByType image/x-icon "access 1 year" | |
ExpiresByType image/jpg "access 1 year" | |
ExpiresByType image/jpeg "access 1 year" | |
ExpiresByType image/png "access 1 year" | |
ExpiresByType image/gif "access 1 year" | |
ExpiresDefault "access 1 month" | |
</IfModule> | |
# Cache-Control Headers | |
<IfModule mod_expires.c> | |
<IfModule mod_headers.c> | |
<filesMatch "\.(ico|jpe?g|png|gif|swf)$"> | |
Header append Cache-Control "public" | |
</filesMatch> | |
<filesMatch "\.(css)$"> | |
Header append Cache-Control "public" | |
</filesMatch> | |
<filesMatch "\.(js)$"> | |
Header append Cache-Control "private" | |
</filesMatch> | |
<filesMatch "\.(x?html?|php)$"> | |
Header append Cache-Control "private, must-revalidate" | |
</filesMatch> | |
</IfModule> | |
</IfModule> | |
# Disable ETags | |
<IfModule mod_headers.c> | |
Header unset ETag | |
</IfModule> | |
FileETag None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment