Skip to content

Instantly share code, notes, and snippets.

@hmngwy
Last active December 3, 2015 16:56
Show Gist options
  • Save hmngwy/8bd74148e003bbd4d8a7 to your computer and use it in GitHub Desktop.
Save hmngwy/8bd74148e003bbd4d8a7 to your computer and use it in GitHub Desktop.
Htaccess Base Directives, Pagespeed Leverage Browser Caching, Enable Compression
## 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-javascript "now plus 1 months"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## 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>
## ALT. COMPRESSION
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<IfModule pagespeed_module>
ModPagespeed on
ModPagespeedStaticAssetPrefix [CHANGE TO ABS PATH TO SITE ROOT]
ModPagespeedDisableFilters inline_css,inline_javascript
ModPagespeedEnableFilters move_css_to_head
ModPagespeedEnableFilters flatten_css_imports
ModPagespeedEnableFilters outline_css,outline_javascript
ModPagespeedEnableFilters combine_css,combine_javascript
ModPagespeedEnableFilters rewrite_css,rewrite_javascript
ModPagespeedEnableFilters remove_comments,collapse_whitespace, elide_atttributes
ModPagespeedEnableFilters rewrite_images
ModPagespeedEnableFilters insert_dns_prefetch
ModPagespeedEnableFilters defer_javascript
#
ModPagespeedEnableFilters inline_preview_images
ModPagespeedEnableFilters resize_mobile_images
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment