ExpiresActive on ExpiresByType text/html "access plus 0 seconds" Header set Referrer-Policy "no-referrer-when-downgrade" # Avoid recompressing already compressed files SetEnvIfNoCase Request_URI \.gz$ no-gzip RewriteEngine On RewriteBase $base RewriteRule .* - [E=SWPSP_SCHEME:-http] RewriteRule .* - [E=SWPSP_EXT:html] RewriteCond %{HTTPS} on [OR] RewriteCond %{SERVER_PORT} ^443$ [OR] RewriteCond %{HTTP:X-Forwarded-Proto} https RewriteRule .* - [E=SWPSP_SCHEME:-https] AddType text/html .gz AddEncoding gzip .gz AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon application/json application/vnd.ms-access video/webm application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.presentation application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint image/svg+xml application/x-shockwave-flash image/tiff application/x-font-ttf application/vnd.ms-opentype audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel # DEFLATE by extension AddOutputFilter DEFLATE js css htm html xml RewriteCond %{HTTP:Accept-Encoding} gzip RewriteRule .* - [E=SWPSP_EXT:gz] # Fallback if the extension is gz but a gz file was never created, check for a .html extension RewriteCond %{ENV:SWPSP_EXT} =gz RewriteCond "%{DOCUMENT_ROOT}$base$cache_path/%{HTTP_HOST}/%{REQUEST_URI}/index%{ENV:SWPSP_SCHEME}.gz" !-f RewriteCond "$site_cache_path/%{REQUEST_URI}/index%{ENV:SWPSP_SCHEME}.gz" !-f RewriteRule .* - [E=SWPSP_EXT:html] RewriteCond %{REQUEST_METHOD} GET RewriteCond %{QUERY_STRING} ^$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP:Cookie} !(wordpress_logged_in_.+|wp-postpass_|wptouch_switch_toggle|comment_author_|comment_author_email_) [NC] RewriteCond %{REQUEST_URI} !^(/(?:.+/)?feed(?:/(?:.+/?)?)?$|/(?:.+/)?embed/|/(index.php/)?(.*)wp-json(/.*|$))$ [NC] RewriteCond "%{DOCUMENT_ROOT}$base$cache_path/%{HTTP_HOST}/%{REQUEST_URI}/index%{ENV:SWPSP_SCHEME}.%{ENV:SWPSP_EXT}" -f [OR] RewriteCond "$site_cache_path/%{REQUEST_URI}/index%{ENV:SWPSP_SCHEME}.%{ENV:SWPSP_EXT}" -f RewriteRule .* "$base$cache_path/%{HTTP_HOST}/%{REQUEST_URI}/index%{ENV:SWPSP_SCHEME}.%{ENV:SWPSP_EXT}" [L] # Detect if a cached file was served and set the proper headers FileETag None Header unset ETag Header unset Pragma Header append Cache-Control "public" Header append Vary: Accept-Encoding Header always set X-Cached-By "Solid Performance (htaccess)" Header set X-Cache "HIT" RULES; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, StellarWP.XSS.EscapeOutput.OutputNotEscaped echo apply_filters( 'solidwp/performance/htaccess/rules', $htaccess, $cache_path );