WPIntell

Source evidence

Gzip setup results in 500 Internal Server Error

Merge + Minify + Refresh · support · 2024-05-15T09:08:00+00:00

mixedsentiment
mediumseverity
0.84relevance
9replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

3 / 25 rows with source links

12.0% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

22 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Oliver Campion resolved
Hello, Following your instructions to add support for .css.gz and .js.gz by adding the following lines to .htaccess … #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,E=is_gzip:1] RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=is_gzip:1] Header set Content-Encoding "gzip" env=is_gzip This results in pages not being served at all with the following error … 500 Internal Server Error Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at admin@localhost to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. Apache/2.4.41 (Ubuntu) Server Port 443 Please advise. Oliver Hi Oliver, Do you have mod_deflate and mod_rewrite enabled? I believe so … ssh@localhost:~# apachectl -M Loaded Modules: core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) actions_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) filter_module (shared) mime_module (shared) mpm_prefork_module (shared) negotiation_module (shared) proxy_module (shared) proxy_fcgi_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) socache_shmcb_module (shared) ssl_module (shared) status_module (shared) ok, I’m not exactly sure. I don’t get any errors when I use it. I’m testing it on a standard WHM/cPanel setup. Are there any more details in the apache logs? You could try css or js on its own and see if either work. That might help identify the problem. Good shout. The issue was we didn’t have a2enmod headers enabled. Might be worth updating readme.txt to ensure users know to have those three mods enabled for Gzip. The page now loads but inspecting the sources, looks like the regular .css and .js files are being served? Tested in Chrome and Safari. Would you mind confirming? https://williamstewart.me I’ve looked on the server and the corresponding .css.gz and .js.gz files all exist within /wp-content/mmr/ Great. I will update the readme. Those rewrites are meant to serve the gzipped version of the css or js and the url stays the same so it should be working. If you need to double check you can modify the generated css but not the gz version.. then you should be able to determine that the correct files is being served. OK, it’s working. Thank you. Looks like the browser automatically gunzips the .gz file. Thank you. Oliver Hello again, we have modified your .htaccess rules as follows which will prevent errors if the headers aren’t enabled … # BEGIN Serve gzip compressed CSS and JS files <IfModule mod_rewrite.c> <IfModule mod_deflate.c> <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,E=is_gzip:1] RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=is_gzip:1] Header set Content-Encoding "gzip" env=is_gzip </IfModule> </IfModule> </IfModule> # END Serve gzip compressed CSS and JS files Feel free to include this in your readme.txt 🙂 Oliver Nice. I’ve added that in. We’ve added support in Deny All Firewall so if you use that plugin and the firewall is enabled then .htaccess rules will be added.

Comments

9 shown
launchinteractive 2024-05-16T00:35:00+00:00

Hi Oliver, Do you have mod_deflate and mod_rewrite enabled?

Oliver Campion 2024-05-16T07:20:00+00:00

I believe so … ssh@localhost:~# apachectl -M Loaded Modules: core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) actions_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) filter_module (shared) mime_module (shared) mpm_prefork_module (shared) negotiation_module (shared) proxy_module (shared) proxy_fcgi_module (shared) reqtimeout_module (shared) rewrite_module (shared) setenvif_module (shared) socache_shmcb_module (shared) ssl_module (shared) status_module (shared)

launchinteractive 2024-05-17T04:09:00+00:00

ok, I’m not exactly sure. I don’t get any errors when I use it. I’m testing it on a standard WHM/cPanel setup. Are there any more details in the apache logs? You could try css or js on its own and see if either work. That might help identify the problem.

Oliver Campion 2024-05-17T08:57:00+00:00

Good shout. The issue was we didn’t have a2enmod headers enabled. Might be worth updating readme.txt to ensure users know to have those three mods enabled for Gzip. The page now loads but inspecting the sources, looks like the regular .css and .js files are being served? Tested in Chrome and Safari. Would you mind confirming? https://williamstewart.me I’ve looked on the server and the corresponding .css.gz and .js.gz files all exist within /wp-content/mmr/

launchinteractive 2024-05-17T10:48:00+00:00

Great. I will update the readme. Those rewrites are meant to serve the gzipped version of the css or js and the url stays the same so it should be working. If you need to double check you can modify the generated css but not the gz version.. then you should be able to determine that the correct files is being served.

Oliver Campion 2024-05-17T13:58:00+00:00

OK, it’s working. Thank you. Looks like the browser automatically gunzips the .gz file. Thank you. Oliver

Oliver Campion 2024-05-18T12:37:00+00:00

Hello again, we have modified your .htaccess rules as follows which will prevent errors if the headers aren’t enabled … # BEGIN Serve gzip compressed CSS and JS files <IfModule mod_rewrite.c> <IfModule mod_deflate.c> <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,E=is_gzip:1] RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=is_gzip:1] Header set Content-Encoding "gzip" env=is_gzip </IfModule> </IfModule> </IfModule> # END Serve gzip compressed CSS and JS files Feel free to include this in your readme.txt 🙂 Oliver

launchinteractive 2024-05-19T23:19:00+00:00

Nice. I’ve added that in.

Oliver Campion 2024-05-20T13:45:00+00:00

We’ve added support in Deny All Firewall so if you use that plugin and the firewall is enabled then .htaccess rules will be added.