From f84911c7d6c820aa42457d714957ad75ad89f0e4 Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Wed, 24 Jun 2015 19:37:39 +0100 Subject: [PATCH 1/2] First attempt at an .htaccess compression doc One of these days I'll learn to keep my danged mouth shut. --- .../htaccess-tweaks-for-performance.textile | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 configuration/htaccess-tweaks-for-performance.textile diff --git a/configuration/htaccess-tweaks-for-performance.textile b/configuration/htaccess-tweaks-for-performance.textile new file mode 100644 index 00000000..7636af45 --- /dev/null +++ b/configuration/htaccess-tweaks-for-performance.textile @@ -0,0 +1,65 @@ +h1. Deflating pages for improved performance + +This article is intended to help Textpattern administrators implement web server compression techniques to improve page load times. + +h2. Background + +The Apache httpd web serving software can optionally perform server-side compression of Textpattern's pages and feeds with an module. Compressed pages and feeds will appear visually identically to the uncompressed version, but typically involve fewer bytes being transferred by the browser. + +h2. .htaccess background + +Apache httpd compression is controlled at a global or per-site basis. Webmasters can use the @.htaccess@ file to control file compression on a per-site basis. + +h2. Setup and configuration + +Many shared web hosting packages have the ability to serve compressed files, though this is not always enabled by default. File compression adds a computational cost to the Apache server by way of increased workload to dynamically compress the files, but the typical result is a significant saving of bytes transferred to the browser. + +The simplest way to confirm if a Textpattern host is serving compressed files is to add a conditional directive to @.htaccess@ and then check for compression in either the browser inspector or via a third-party service. + +h3. .htaccess file modifications + +Confirm which version of Apache the Textpattern instance is using via Admin -> Diagnostics. Add the appropriate code to the Textpattern @.htaccess@ file: + +h4. For Apache 2.x + +bc. +AddOutputFilterByType DEFLATE text/css +AddOutputFilterByType DEFLATE text/plain +AddOutputFilterByType DEFLATE text/html +AddOutputFilterByType DEFLATE text/xml +AddOutputFilterByType DEFLATE application/xml +AddOutputFilterByType DEFLATE application/xhtml+xml +AddOutputFilterByType DEFLATE application/rss+xml +AddOutputFilterByType DEFLATE application/javascript +AddOutputFilterByType DEFLATE application/x-javascript +BrowserMatch ^Mozilla/4 gzip-only-text/html +BrowserMatch ^Mozilla/4\.0[678] no-gzip +BrowserMatch \bMSIE !no-gzip !gzip-only-text/html + + +h4. For Apache 1.x + + +AddOutputFilterByType DEFLATE text/css +AddOutputFilterByType DEFLATE text/plain +AddOutputFilterByType DEFLATE text/html +AddOutputFilterByType DEFLATE text/xml +AddOutputFilterByType DEFLATE application/xml +AddOutputFilterByType DEFLATE application/xhtml+xml +AddOutputFilterByType DEFLATE application/rss+xml +AddOutputFilterByType DEFLATE application/javascript +AddOutputFilterByType DEFLATE application/x-javascript +BrowserMatch ^Mozilla/4 gzip-only-text/html +BrowserMatch ^Mozilla/4\.0[678] no-gzip +BrowserMatch \bMSIE !no-gzip !gzip-only-text/html + + +h3. Check files are compressed + +Many modern browser inspectors will indicate whether a web page resource is compressed, and third-party services exist to do the same thing. The simplest way to confirm if content of a given type is being served compressed is to test the following URLs at an appropriate checker, such as the "HTTP Compression Test":http://www.whatsmyip.org/http-compression-test/ page at @whatsmyip.org@, where @example.com@ is the address of the Textpattern site: + +* @http://example.com/css?n=default@ +* @http://example.com/textpattern/checksums.txt@ +* @http://example.com/index.php@ +* @http://example.com/rss@ +* @http://example.com/textpattern/textpattern.js@ \ No newline at end of file From 0199403593409537a35ef45847915c3915a7091a Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Wed, 24 Jun 2015 19:39:02 +0100 Subject: [PATCH 2/2] Missed a `bc.` --- configuration/htaccess-tweaks-for-performance.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration/htaccess-tweaks-for-performance.textile b/configuration/htaccess-tweaks-for-performance.textile index 7636af45..28b382be 100644 --- a/configuration/htaccess-tweaks-for-performance.textile +++ b/configuration/htaccess-tweaks-for-performance.textile @@ -39,7 +39,7 @@ BrowserMatch \bMSIE !no-gzip !gzip-only-text/html h4. For Apache 1.x - +bc. AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html