Question gzip compression
- jprause
- Topic Author
- Offline
- Senior Member
In webtrees 1.7 it worked OK but it does not work in 2.0.
Could there be some conflict with webtrees?
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
What does not work? Do you get an error? Can we see this?
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- jprause
- Topic Author
- Offline
- Senior Member
My settings:
File .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !^.*on
RewriteRule ^(.*)$ www.jprodina.cz/$1 [R,L]
#
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L]
#
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/font-sfnt
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/vnd.microsoft.icon
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/html
</IfModule>
File user.ini:
zlib.output_compression = On
display_errors = On
HTML is not compressed.
Appendices:
PHP setting see image php-7.4.12.jpg
test gzip with www.gidnetwork.com/tools/gzip-test.php see image gid_network-test.jpg
browser chromium debugger see image browser-debugging.jpg
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
AddOutputFilterByType DEFLATE application/x-httpd-php
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- jprause
- Topic Author
- Offline
- Senior Member
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
I read that PHP scripts are handled separately from other files - which is why your DEFLATE rules do not work.
Perhaps it is necessary to add DEFLATE options to the configuration that handles PHP scripts...
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- ddrury
- Offline
- Senior Member
www.valendigital.co.uk/blog/optimise-you...th-gzip-compression/
--
Dave
Local: Win 11 Pro, WSL2/Ubuntu20.04.4, Apache 2.4.51, PHP 7.4.26/8.1.7, MySQL 8.0.27
Production: Litespeed 8.0.1, PHP 8.1.9, MySQL 8.0.26
Please Log in or Create an account to join the conversation.
- jprause
- Topic Author
- Offline
- Senior Member
besides webtrees 2.0 there are two WordPress sites, two Mediawiki sites and one Piwigo.
All of them are successfuly gzip compressed.
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.
- jprause
- Topic Author
- Offline
- Senior Member
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
e.g. update data/config.ini.php and remove .htaccess
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- jprause
- Topic Author
- Offline
- Senior Member
Btw, only the content-type text/html is not compressed. Content-types text/css and application/javascript are gzip compressed.
I think you could see it in your browser.
EDIT:
hosting support asks me whether there is something like
I do not know.
I tried to find the string "gzip" in webtrees code.
It only matches 11 times in folder "vendor" but this is far beyond my PHP knowledge.
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
> header('Content-Encoding: gzip');
No. This is normally added by the webserver (apache/nginx)
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- jprause
- Topic Author
- Offline
- Senior Member
On this website (i.e. test.jprodina.cz ) gzip compression works as expected.
(See picture)
I guess there must be some difference in some code in folder /vendor/guzzlehttp (this is a black box for me) between 1.7 and 2.0 as to the html compression.
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.
- jprause
- Topic Author
- Offline
- Senior Member
There are no third-party modules, no CSS&JS modification.
Settings in .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !^.*on
RewriteRule ^(.*)$ test.jprodina.cz/$1 [R,L]
#
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L]
#
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/font-sfnt
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/vnd.microsoft.icon
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/html
</IfModule>
In .user.ini:
zlib.output_compression = On
This are recommended settings for gzip compression.
The result is that "content-type: text/html" are not compressed whereas css and javascript are compressed, see appendices.
The hosting support says that the application webtrees is somehow blocking text/html compression.
Can you help please?
May I ask somebody of the webtrees community to try to set gzip compression for their webtrees 2.0.10 website and share their experience?
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.
- fisharebest
- Offline
- Administrator
Does it help if you add a line to your .htaccess:
<IfModule mod_deflate.c>
Header unset Content-Length
Greg Roach - greg@subaqua.co.uk - @fisharebest@phpc.social - fisharebest.webtrees.net
Please Log in or Create an account to join the conversation.
- jprause
- Topic Author
- Offline
- Senior Member
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.
- ddrury
- Offline
- Senior Member
1. Implemented removal of ETag
2. Added far-future expiration dates.
Adding these lines really improved the responsiveness of the site, all the static stuff gets cached and the remainder either benefits from chunking or is small enough to get compressed.
I initially added the content transformation lines
--
Dave
Local: Win 11 Pro, WSL2/Ubuntu20.04.4, Apache 2.4.51, PHP 7.4.26/8.1.7, MySQL 8.0.27
Production: Litespeed 8.0.1, PHP 8.1.9, MySQL 8.0.26
Please Log in or Create an account to join the conversation.
- ddrury
- Offline
- Senior Member
It seems likely that there are instances in wt2.0 where Apache's DeflateBufferSize (default is 8k) is exceeded resulting in the transfer being chunked where in 1.7 it falls below the limit
--
Dave
Local: Win 11 Pro, WSL2/Ubuntu20.04.4, Apache 2.4.51, PHP 7.4.26/8.1.7, MySQL 8.0.27
Production: Litespeed 8.0.1, PHP 8.1.9, MySQL 8.0.26
Please Log in or Create an account to join the conversation.
- eh215
- Offline
- Senior Member
Here is what I have in my Apache .htaccess file to turn on compression and caching. While I have not tested every possible page, all of my spot-checks show that both compression and caching are being applied as expected.
I originally set the compression up by specific file type but have since modified it to compress by default as shown below. It might need updating if I hosted a wide variety of media types (sound, videos, etc) but I have no plans for that so it works for the content that I have. I am also on 2.0.10.
Please Log in or Create an account to join the conversation.
- jprause
- Topic Author
- Offline
- Senior Member
I tested your .htaccess setting on my testing site .
Alas the "content-type: text/html" components are still not gzip compressed.
Josef
webhosting:-- webtrees 2.1.18, PHP version 8.1.16, MySQL 8.0.22, test site webtrees 2.1.18
local desktop:-- webtrees 2.1.18, PHP version 8.2.12, MySQL 8.0.28, Apache2 2.4.41, Linux Ubuntu 22.04 64bit
Please Log in or Create an account to join the conversation.