Pre-compressed Gzip – Speed boost!
-
Apache Server Gzip Configuration (htaccess)
I checked recently the FVM generated files found in [cache directory]/fvm/out/ and discovered 3 files generated for each resource (css or js).
- 1. The merged file .css/.js (used for browser)
- 2. The plugin info file .txt (used on FVM Status tab)
- 3. The 3rd file .gz (gzip)
I believe is generated by the cache plugin WP Super Cache – likely its htaccess directives. I have the setting selected “Compress pages so they’re served more quickly to visitors”.
Generated by FVM.
What a bonus I thought, pre-compressed gzip FVM css/js files!
Go and check the directory [cache directory]/fvm/out/ and if it contains the pre-compressed gzip files, you can take advantage of those and get another 10%+ page load speed!
The following htaccess directives will make sure the resources are served as content-encoding: gzip, whether they are pre-compressed or not, and set appropriate cache control – expires & security – headers too. If the gzip files exist, it will load page/resources just that little bit faster…
Just add the following to the document root .htaccess file to get the added boost:# ===== BEGIN GZIP ===== # ===== Cache Control and Enable CORS ===== <FilesMatch "\.(js|css|jpg|gif|png|pdf|swf|svg|svgz|ico|ttf|ttc|otf|eot|woff|woff2|webp)$"> <IfModule mod_headers.c> ExpiresActive On ExpiresDefault "access plus 1 month" Header set Cache-Control "public, immutable, max-age=2628000, s-maxage=2628000" Header set Access-Control-Allow-Origin "*" </IfModule> </FilesMatch> # Compression by Type # text/html removed to allow cached gzip compression by Supercache (add below if required) <ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE text/css text/javascript text/plain text/xml application/javascript </ifmodule> <IfModule mod_headers.c> # Serve gzip compressed CSS files if they exist and the client accepts gzip. RewriteCond "%{HTTP:Accept-encoding}" "gzip" RewriteCond "%{REQUEST_FILENAME}\.gz" -s RewriteRule "^(.*)\.css" "$1\.css\.gz" [QSA] # Serve gzip compressed JS files if they exist and the client accepts gzip. RewriteCond "%{HTTP:Accept-encoding}" "gzip" RewriteCond "%{REQUEST_FILENAME}\.gz" -s RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA] # Serve correct content types, and prevent mod_deflate double gzip. RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1] RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1] # Serve correct encoding type, and cache control <FilesMatch "(\.js\.gz|\.css\.gz)$"> Header append Content-Encoding gzip ExpiresActive On ExpiresDefault "access plus 1 month" Header set Cache-Control "public, immutable, max-age=2628000, s-maxage=2628000" Header set Access-Control-Allow-Origin "*" </FilesMatch> </IfModule> # ===== END GZIP =====
To test on your browser, right-click on a web page, select Inspect or Inspect Element then click the “Network” tab at top. Load/reload page then…
Scroll thru the files list and click on CSS or JS file to view headers. Should include:
content-encoding: gzip
vary: Accept-Encoding
expires: [future date]All good!
- The topic ‘Pre-compressed Gzip – Speed boost!’ is closed to new replies.