Last active
January 7, 2018 19:51
-
-
Save vanaf1979/ead0c3cb04c7623c7384ef08941cfbe8 to your computer and use it in GitHub Desktop.
Compression, Expiration and Cache control Htaccess rules to speed up Wordpress
This file contains 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
# | |
### HTACCESS RULES TO SPEED UP WORDPRESS | |
# | |
### / START DEFLATE COMPRESSION | |
<IfModule mod_deflate.c> | |
AddOutputFilterByType DEFLATE application/javascript | |
AddOutputFilterByType DEFLATE application/rss+xml | |
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject | |
AddOutputFilterByType DEFLATE application/x-font | |
AddOutputFilterByType DEFLATE application/x-font-opentype | |
AddOutputFilterByType DEFLATE application/x-font-otf | |
AddOutputFilterByType DEFLATE application/x-font-truetype | |
AddOutputFilterByType DEFLATE application/x-font-ttf | |
AddOutputFilterByType DEFLATE application/x-javascript | |
AddOutputFilterByType DEFLATE application/xhtml+xml | |
AddOutputFilterByType DEFLATE application/xml | |
AddOutputFilterByType DEFLATE font/opentype | |
AddOutputFilterByType DEFLATE font/otf | |
AddOutputFilterByType DEFLATE font/ttf | |
AddOutputFilterByType DEFLATE image/svg+xml | |
AddOutputFilterByType DEFLATE image/x-icon | |
AddOutputFilterByType DEFLATE text/css | |
AddOutputFilterByType DEFLATE text/html | |
AddOutputFilterByType DEFLATE text/javascript | |
AddOutputFilterByType DEFLATE text/plain | |
AddOutputFilterByType DEFLATE text/xml | |
</IfModule> | |
### \ END DEFLATE COMPRESSION | |
### / START GZIP COMPRESSION | |
<IfModule mod_gzip.c> | |
mod_gzip_on Yes | |
mod_gzip_dechunk Yes | |
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ | |
mod_gzip_item_include handler ^cgi-script$ | |
mod_gzip_item_include mime ^text/.* | |
mod_gzip_item_include mime ^application/x-javascript.* | |
mod_gzip_item_exclude mime ^image/.* | |
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* | |
</IfModule> | |
### \ END GZIP COMPRESSION | |
### / START EXPIRATION HEADERS | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresDefault "now plus 1 hour" | |
ExpiresByType text/css "now plus 1 week" | |
ExpiresByType application/javascript "now plus 1 week" | |
ExpiresByType application/x-javascript "now plus 1 week" | |
ExpiresByType image/bmp "now plus 1 month" | |
ExpiresByType image/gif "now plus 1 month" | |
ExpiresByType image/jpeg "now plus 1 month" | |
ExpiresByType image/jp2 "now plus 1 month" | |
ExpiresByType image/pipeg "now plus 1 month" | |
ExpiresByType image/png "now plus 1 month" | |
ExpiresByType image/svg+xml "now plus 1 month" | |
ExpiresByType image/tiff "now plus 1 month" | |
ExpiresByType image/vnd.microsoft.icon "now plus 1 month" | |
ExpiresByType image/x-icon "now plus 1 month" | |
ExpiresByType image/ico "now plus 1 month" | |
ExpiresByType image/icon "now plus 1 month" | |
ExpiresByType text/ico "now plus 1 month" | |
ExpiresByType application/ico "now plus 1 month" | |
ExpiresByType font/truetype "access plus 1 month" | |
ExpiresByType font/opentype "access plus 1 month" | |
ExpiresByType application/x-font-woff "access plus 1 month" | |
ExpiresByType image/svg+xml "access plus 1 month" | |
ExpiresByType application/vnd.ms-fontobject "access plus 1 month" | |
</IfModule> | |
### \ END EXPIRATION HEADERS | |
### / START CACHE-CONTROL HEADERS | |
<ifModule mod_headers.c> | |
<filesMatch "\.(ico|jpe?g|png|gif|swf)$"> | |
Header set Cache-Control "public" | |
</filesMatch> | |
<filesMatch "\.(css)$"> | |
Header set Cache-Control "public" | |
</filesMatch> | |
<filesMatch "\.(js)$"> | |
Header set Cache-Control "private" | |
</filesMatch> | |
<filesMatch "\.(x?html?|php)$"> | |
Header set Cache-Control "private, must-revalidate" | |
</filesMatch> | |
</ifModule> | |
### \ END CACHE-CONTROL HEADERS | |
# Compiled from this article: | |
# https://www.pixelemu.com/documentation/wordpress-tutorials/how-to-speed-up-wordpress-site-htaccess-optimization-part-1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment