Note: This needs to be updated/merged with whatever other documentation I have regarding PageSpeed stuff. 10-28-2019
<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>
AddOutputFilterByType DEFLA TE text/plain AddOutputFilterByType DEFLA TE text/html AddOutputFilterByType DEFLA TE text/xml AddOutputFilterByType DEFLA TE text/css AddOutputFilterByType DEFLA TE application/xml AddOutputFilterByType DEFLA TE application/xhtml+xml AddOutputFilterByType DEFLA TE application/rss+xml AddOutputFilterByType DEFLA TE application/javascript AddOutputFilterByType DEFLA TE application/x-javascript
# BEGIN Expire headers <ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 2 days"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/javascript "access plus 216000 seconds" ExpiresByType application/x-javascript "access plus 216000 seconds" ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
# END Expire headers
# BEGIN Caching <ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|svg)$"> Header set Cache-Control "max-age=2592000, public"
</filesMatch> <filesMatch "\\.(css|js)$">
Header set Cache-Control "max-age=604800, public" </filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=216000, public, must-revalidate" </filesMatch>
<filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=3600, public, must-revalidate" </filesMatch>
</ifModule>
# END Caching
## WEBP switch
RewriteBase /
# IF request from Page Speed
RewriteCond %{HTTP_USER_AGENT} "Google Page Speed Insights" [OR]
# AND does a webp image exists?
RewriteCond %{DOCUMENT_ROOT}/$1\.webp -f
# THEN send the webp image and set the env var webp
RewriteRule (.+)\.(?:jpe?g|png)$ $1.webp [NC,T=image/webp,E=webp,L]
# If REDIRECT_webp env var exists, append Accept to the Vary header Header append Vary Accept env=REDIRECT_webp
## WEBP switch
Header append Vary Accept env=REQUEST_image AddType image/webp .webp
- Wordpress Cache Plugins https://wordpress.org/plugins/autoptimize https://wordpress.org/plugins/autoptimize-criticalcss/
- Pantheon Autoptimize Instructions: https://pantheon.io/docs/modules-plugins-known-issues/
- WordPress Webp plugin https://wordpress.org/plugins/webp-express/
- Drupal Webp plugin https://www.drupal.org/project/webp (requires .htaccess) for Pantheon (and other none-htaccess):
- Drupal Critical CSS https://www.drupal.org/project/critical_css
- Critical Path CSS Generator https://www.sitelocity.com/critical-path-css-generator
<picture>
<source srcset="logo.webp" type="image/webp">
<img src="logo.png" alt="Site Logo"> </picture>