Skip to content

Instantly share code, notes, and snippets.

@carasmo
Last active May 15, 2017 00:29
Show Gist options
  • Save carasmo/4ae7da21f9b254385ecd to your computer and use it in GitHub Desktop.
Save carasmo/4ae7da21f9b254385ecd to your computer and use it in GitHub Desktop.
Speed Up WordPress self hosted sites. This content goes inside the .htaccess file BEFORE the # BEGIN WordPress.
## If your server has a redirect problem with
## .htpasswds protection on wp-admin directory, add the following:
ErrorDocument 401 default
## ------- UNSET PRAGMA ------
## https://www.mnot.net/cache_docs/#PRAGMA
##Pragma HTTP Headers (and why they don't work)
Header unset Pragma
FileETag None
Header unset ETag
## ------- EXPIRES CACHING ------
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
## ------- GZIP ------
## compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/js
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .png
## ----------- End don't touch the #BEGIN WordPress Area -------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment