Web based family history software

Question gzip compression

  • jprause
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 4 months ago - 3 years 4 months ago #1 by jprause
gzip compression was created by jprause
For my webtrees website I have set gzip compression.
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
Last edit: 3 years 4 months ago by jprause.

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago #2 by fisharebest
Replied by fisharebest on topic gzip compression
How did you set gzip compression?

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
  • Senior Member
More
3 years 4 months ago #3 by jprause
Replied by jprause on topic gzip compression
There are no errors in website log.
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
Attachments:

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #4 by fisharebest
Replied by fisharebest on topic gzip compression
Does it help if you add this line:

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
  • Senior Member
More
3 years 3 months ago #5 by jprause
Replied by jprause on topic gzip compression
No this does not help, sorry.

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.

More
3 years 3 months ago #6 by fisharebest
Replied by fisharebest on topic gzip compression
Then I am afraid I do not know.

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.

More
3 years 3 months ago #7 by ddrury
Replied by ddrury on topic 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
  • Senior Member
More
3 years 3 months ago #8 by jprause
Replied by jprause on topic gzip compression
At this moment I'd only like to note that under my domain there are a few other subdomains:
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
  • Senior Member
More
3 years 3 months ago #9 by jprause
Replied by jprause on topic gzip compression
I sent the issue to my webhosting support. Waiting for reply.

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.

More
3 years 3 months ago #10 by fisharebest
Replied by fisharebest on topic gzip compression
Does it make a difference if you disable "pretty URLs"?
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
  • Senior Member
More
3 years 3 months ago - 3 years 3 months ago #11 by jprause
Replied by jprause on topic gzip compression
There is no difference between "pretty" and "ugly" URLs.
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
Code:
header('Content-Encoding: gzip');
in webtrees code.
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
Last edit: 3 years 3 months ago by jprause.

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #12 by fisharebest
Replied by fisharebest on topic gzip compression
> hosting support asks me whether there is something like
> 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
  • Senior Member
More
3 years 3 months ago - 3 years 3 months ago #13 by jprause
Replied by jprause on topic gzip compression
I have installed webtrees 1.7.17 on the same server with the same .htaccess and .user.ini settings.
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
Attachments:
Last edit: 3 years 3 months ago by jprause.

Please Log in or Create an account to join the conversation.

  • jprause
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 3 months ago - 3 years 3 months ago #14 by jprause
Replied by jprause on topic gzip compression
I have installed webtrees 2.0.10 URL test.jprodina.cz/tree/nase-rodina .
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
Attachments:
Last edit: 3 years 3 months ago by jprause.

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #15 by fisharebest
Replied by fisharebest on topic gzip compression
I do not have an apache server for testing - but I have no problem compressing output using nginx.

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
  • Senior Member
More
3 years 3 months ago #16 by jprause
Replied by jprause on topic gzip compression
No, this does not help.

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.

More
3 years 3 months ago #17 by ddrury
Replied by ddrury on topic gzip compression
This topic prompted me to investigate Apache's implementation of compressing or chunking output and to my mind it does a pretty good job and certainly not something to get hung up about, however I did look at github.com/h5bp/html5-boilerplate/blob/m.../dist/.htaccess?ts=2 which has a lot of stuff in it and some bits that I found useful.

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
Code:
<IfModule mod_headers.c> Header merge Cache-Control "no-transform" </IfModule>
but that made the site really slow - for some reason my host really didn't like that and caching went wrong.

--
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.

More
3 years 3 months ago #18 by ddrury
Replied by ddrury on topic gzip compression
A bit more (not exhaustive) investigating reveals an interesting difference between wt1.7 & wt2.0. Using Firefox on my test system and loading my own individual page, the developer tools show for the individual.php line for wt1.7.17 9.70k transferred for a size of 47.69k. For wt2.0.10 the data is 28.25k and 260.07k - whilst still relatively small amounts there is a significant increase for wt2.0.

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.

More
3 years 2 months ago - 3 years 2 months ago #19 by eh215
Replied by eh215 on topic gzip compression
jprause - you raised this topic a few weeks ago but it looks like your site is still having issues trying to compress some components.

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.
Code:
# #Compress everything except images # <ifModule mod_deflate.c> SetOutputFilter DEFLATE SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|pdf)$ no-gzip dont-vary </ifModule> <IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 12 month" </IfModule>
Last edit: 3 years 2 months ago by eh215.

Please Log in or Create an account to join the conversation.

  • jprause
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
3 years 2 months ago #20 by jprause
Replied by jprause on topic gzip compression
@eh215:
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.

Powered by Kunena Forum
}