Compresion GZIP en archivos PHP no funciona
Buenas tardes,
Escribo este hilo porque estoy chequeando mi sitio y he habilitado la compresion gzip pero hay un problema:
FUNCIONA: - Removed -
NO FUNCIONA: - Removed -
Este es mi archivo .htaccess:
Y este mi php.ini
Que puede ocurrir para que no me comprima la web hecha en PHP?
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|assets|revslider|dist|sitemap\.xml|contacto\.php|google359cc7244751e9c3\.html|.well-known|sign\.html|sign_host\.html|sign\.png)
RewriteRule ^(.*)$ index.php/$1 [L]
# php -- BEGIN cPanel-generated handler, do not edit
# Configure el paquete "ea-php70" como el lenguaje de programaci"n predeterminado "PHP".
AddType application/x-httpd-ea-php70 .php .php7 .phtml
# php -- END cPanel-generated handler, do not edit
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
php_flag display_errors Off
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 256M
php_value post_max_size 20M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php70"
php_value upload_max_filesize 15M
php_flag zlib.output_compression On
php_value output_handler ob_gzhandler
# END cPanel-generated php ini directives, do not edit
Y este mi php.ini
; cPanel-generated php ini directives, do not edit
; Manual editing of this file may result in unexpected behavior.
; To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
; For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
display_errors = Off
max_execution_time = 30
max_input_time = 60
max_input_vars = 1000
memory_limit = 256M
post_max_size = 20M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php70"
upload_max_filesize = 15M
zlib.output_compression = On
Que puede ocurrir para que no me comprima la web hecha en PHP?
-
Hello @50l3r, Have you enabled compression using the Optimize Website feature in cPanel? If so, can you confirm the specific method you are using to test if compression is enabled? Thank you. Translation: Hola @50l3r, "Ha habilitado la compresi"n utilizando la funci"n Optimizar sitio web en cPanel? De ser as", "puede confirmar el m"todo espec"fico que est" utilizando para probar si la compresi"n est" habilitada? Gracias. 0 -
Hola @50l3r, Remember that the gzip compression does not compress the php file itself, but compresses the output that the php file creates Look for Content-Encoding: gzip in the page response headers. ------------- Recuerde que la compresi"n gzip no comprime el archivo php, sino que comprime la salida que crea el archivo php. Busque Content-Encoding: gzip en los encabezados de respuesta de la p"gina. 0 -
He probado con "optimizar el sitio web" y marcar "todo" pero no funciona Chequeo en esta pagina web:
But it does not work In phpinfo...https://i.gyazo.com/5e3e098b3c517a244342802e7480438f.png
0 -
Hello @50l3r, Can you run the following command for one of your website pages and let us know the output? curl -v --compressed http://domain.tld/test.php
Ensure to use CODE tags and replace real domain names and IP addresses with examples when pasting the output in your response. Thank you. Hola @ 50l3r, "Puedes ejecutar el siguiente comando para una de las p"ginas de tu sitio web y dejarnos saber el resultado?curl -v --compressed http://domain.tld/test.php
Aseg"rese de usar etiquetas CODE y reemplace nombres de dominio reales y direcciones IP con ejemplos al pegar el resultado en su respuesta. Gracias.0 -
Hello @50l3r, Can you run the following command for one of your website pages and let us know the output?
curl -v --compressed http://domain.tld/test.php
Ensure to use CODE tags and replace real domain names and IP addresses with examples when pasting the output in your response. Thank you. Hola @ 50l3r, "Puedes ejecutar el siguiente comando para una de las p"ginas de tu sitio web y dejarnos saber el resultado?curl -v --compressed http://domain.tld/test.php
Aseg"rese de usar etiquetas CODE y reemplace nombres de dominio reales y direcciones IP con ejemplos al pegar el resultado en su respuesta. Gracias.
* About to connect() to removed.tld port 80 (#0) * Trying removed... * Connected to removed.tld (removed) port 80 (#0) > GET /index.php HTTP/1.1 > User-Agent: curl/7.29.0 > Host: removed.tld > Accept: */* > Accept-Encoding: deflate, gzip > < HTTP/1.1 302 Found < Date: Fri, 14 Sep 2018 00:24:36 GMT < Server: Apache < Vary: Accept-Encoding < Location: https://removed.tld/index.php < Transfer-Encoding: chunked < Content-Type: text/html; charset=UTF-8 < * Connection #0 to host removed.tld left intact0 -
Hello @50l3r, It looks like the custom redirect rules in your .htaccess file are the culprit. You may want to try temporarily removing the custom redirect rules and then testing again to confirm they are the cause of the issue. If the content is compressed after removing the custom redirect rules, then you'd want to check with a website developer to see how you might adjust those rules to ensure compression still works. Thank you. 0 -
Hello @50l3r, It looks like the custom redirect rules in your .htaccess file are the culprit. You may want to try temporarily removing the custom redirect rules and then testing again to confirm they are the cause of the issue. If the content is compressed after removing the custom redirect rules, then you'd want to check with a website developer to see how you might adjust those rules to ensure compression still works. Thank you.
He reducido mi htaccess a esto:# BEGIN cPanel-generated php ini directives, do not edit # Manual editing of this file may result in unexpected behavior. # To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor) # For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI) php_flag display_errors Off php_value max_execution_time 30 php_value max_input_time 60 php_value max_input_vars 1000 php_value memory_limit 256M php_value post_max_size 20M php_value session.gc_maxlifetime 1440 php_value session.save_path "/var/cpanel/php/sessions/ea-php70" php_value upload_max_filesize 15M php_flag zlib.output_compression On # END cPanel-generated php ini directives, do not edit
Pero sigue sin funcionar correctamente:[root@bravo ~]# curl -v --compressed http://removed.tld/index.php * About to connect() to removed.tld port 80 (#0) * Trying removed... * Connected to calltek.es (removed) port 80 (#0) > GET /index.php HTTP/1.1 > User-Agent: curl/7.29.0 > Host: calltek.es > Accept: */* > Accept-Encoding: deflate, gzip > < HTTP/1.1 302 Moved Temporarily < Date: Fri, 14 Sep 2018 19:05:58 GMT < Server: Apache < Vary: Accept-Encoding < Location: https://removed.tld/index.php < Transfer-Encoding: chunked < Content-Type: text/html; charset=UTF-8 < * Connection #0 to host removed.tld left intact0 -
I found this in Stackoverflow - you could try adding it to your .htaccess file and seeing if it works ! Encontr" esto en Stackoverflow: "podr"as intentar agregarlo a tu archivo .htaccess y ver si funciona! # force deflate for mangled headers # developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding # HTML, TXT, CSS, JavaScript, JSON, XML, HTC: FilterDeclare COMPRESS FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype FilterChain COMPRESS FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no # Legacy versions of Apache AddOutputFilterByType DEFLATE text/html text/plain text/css application/json AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE text/xml application/xml text/x-component AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml AddOutputFilterByType DEFLATE application/atom+xml AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font-ttf font/opentype #Apache deflate module is not defined, active the page compression through PHP ob_gzhandler php_flag output_buffering On php_value output_handler ob_gzhandler0 -
I found this in Stackoverflow - you could try adding it to your .htaccess file and seeing if it works ! Encontr" esto en Stackoverflow: "podr"as intentar agregarlo a tu archivo .htaccess y ver si funciona!
# force deflate for mangled headers # developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding # HTML, TXT, CSS, JavaScript, JSON, XML, HTC: FilterDeclare COMPRESS FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript FilterProvider COMPRESS DEFLATE resp=Content-Type $application/json FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/xhtml+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/rss+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/atom+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/vnd.ms-fontobject FilterProvider COMPRESS DEFLATE resp=Content-Type $image/svg+xml FilterProvider COMPRESS DEFLATE resp=Content-Type $application/x-font-ttf FilterProvider COMPRESS DEFLATE resp=Content-Type $font/opentype FilterChain COMPRESS FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no # Legacy versions of Apache AddOutputFilterByType DEFLATE text/html text/plain text/css application/json AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE text/xml application/xml text/x-component AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml AddOutputFilterByType DEFLATE application/atom+xml AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font-ttf font/opentype #Apache deflate module is not defined, active the page compression through PHP ob_gzhandler php_flag output_buffering On php_value output_handler ob_gzhandler
Me daba este error en FilterProvider:[Sat Sep 15 16:07:24.192677 2018] [core:alert] [pid 5733] [client 62.42.153.102:34825] /home/calltek/public_html/.htaccess: FilterProvider takes three arguments, filter-name provider-name match-expression
Consegu" solucionarlo y este es mi htaccess ahora:RewriteEngine on RewriteBase / RewriteCond $1 !^(index\.php|assets|revslider|dist|sitemap\.xml|contacto\.php|google359cc7244751e9c3\.html|.well-known|sign\.html|sign_host\.html|sign\.png) RewriteRule ^(.*)$ index.php/$1 [L] # php -- BEGIN cPanel-generated handler, do not edit # Configure el paquete "ea-php70" como el lenguaje de programaci"n predeterminado "PHP". AddType application/x-httpd-ea-php70 .php .php7 .phtml # php -- END cPanel-generated handler, do not edit # BEGIN cPanel-generated php ini directives, do not edit # Manual editing of this file may result in unexpected behavior. # To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor) # For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI) php_flag display_errors Off php_value max_execution_time 30 php_value max_input_time 60 php_value max_input_vars 1000 php_value memory_limit 64M php_value post_max_size 20M php_value session.gc_maxlifetime 1440 php_value session.save_path "/var/cpanel/php/sessions/ea-php70" php_value upload_max_filesize 15M php_flag zlib.output_compression On # force deflate for mangled headers # developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding # HTML, TXT, CSS, JavaScript, JSON, XML, HTC: FilterDeclare COMPRESS FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'text/html'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'text/css'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'text/plain'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'text/xml'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'text/x-component'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'application/javascript'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'application/json'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'application/xml'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'application/xhtml+xml'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'application/rss+xml'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'application/atom+xml'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'application/vnd.ms-fontobject'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'image/svg+xml'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'image/x-icon'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'application/x-font-ttf'" FilterProvider COMPRESS DEFLATE "%{Content_Type} = 'font/opentype'" FilterChain COMPRESS FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no # Legacy versions of Apache AddOutputFilterByType DEFLATE text/html text/plain text/css application/json AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE text/xml application/xml text/x-component AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml AddOutputFilterByType DEFLATE application/atom+xml AddOutputFilterByType DEFLATE image/svg+xml application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font-ttf font/opentype #Apache deflate module is not defined, active the page compression through PHP ob_gzhandler php_flag output_buffering On php_value output_handler ob_gzhandler
Pero lamentablemente sigue sin comprimir0 -
Solucionado. El problema era del propio script no del htaccess 0 -
Gracias por la actualizacion. Me alegra que hayas encontrado cu"l era el problema. 0 -
Solucionado. El problema era del propio script no del htaccess
I'm happy to see the issue is solved. Can you share any information about what in-particular about the script caused the problem? Thank you. Translation: Estoy feliz de ver que el problema est" resuelto. "Puede compartir cualquier informaci"n sobre qu" en particular sobre el gui"n caus" el problema? Gracias.0
Please sign in to leave a comment.
Comments
12 comments