• Resolved Mentik Yusmantara

    (@mentikyusmantara)


    Hello i’am implemented the original .htacces’s W3TC Configuration for more than 7 month.

    # BEGIN W3TC Minify cache
    <IfModule mod_mime.c>
        AddType text/css .css_gzip
        AddEncoding gzip .css_gzip
        AddType application/x-javascript .js_gzip
        AddEncoding gzip .js_gzip
    </IfModule>
    <IfModule mod_deflate.c>
        <IfModule mod_setenvif.c>
            SetEnvIfNoCase Request_URI \.css_gzip$ no-gzip
            SetEnvIfNoCase Request_URI \.js_gzip$ no-gzip
        </IfModule>
    </IfModule>
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType text/css M10713600
        ExpiresByType application/x-javascript M10713600
    </IfModule>
    <IfModule mod_headers.c>
        Header set Vary "Accept-Encoding"
    </IfModule>
    # END W3TC Minify cache
    # BEGIN W3TC Minify core
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /wp-content/cache/minify/
        RewriteCond %{HTTP:Accept-Encoding} gzip
        RewriteRule .* - [E=APPEND_EXT:_gzip]
        RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -F
        RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]
        RewriteRule ^(.+\.(css|js))$ /index.php [L]
    </IfModule>
    # END W3TC Minify core

    After i move to unmanaged VPS, i found this configuration make error

    [Mon May 18 00:10:15.806084 2020] [core:error] [pid 28361] [client 114.125.100.87:52499] AH00125: Request exceeded the limit of 10 subrequest nesting levels due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: ...

    Then i set to LogLevel debug in httpd.conf
    This problem come

    [Mon May 18 03:54:08.450949 2020] [core:debug] [pid 5046] core.c(3848): [client 139.0.199.184:49631] AH00121: r->uri = /wp-content/script/gzip/xxxxxx.v1.min.js_gzip_gzip_gzip_gzip_gzip_gzip_gzip_gzip_gzip_gzip, referer: ~

    I resolved the issue
    Using this configuration

    <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]
        RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1]
    
        <FilesMatch "(\.js\.gz|\.css\.gz)$">
          # Serve correct encoding type.
          Header append Content-Encoding gzip
    
          # Force proxies to cache gzipped & 
          # non-gzipped css/js files separately.
          Header append Vary Accept-Encoding
        </FilesMatch>
    </IfModule>

    This script was created by Mattias Greniad, i test the script work in Apache 2.4
    I just implemented the script for my custom per-compiled file using 7z software to create static .gz. The error resolved by its script.

    Can w3TC, analyze the .htaccess script and also W3TC can make the plugin more compatible with other server management (i am using direct admin)

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @mentikyusmantara
    Thank you for your inquiry and I am happy to assist you with this.
    As I recall you’ve had some issues enabling gzip compression on your server.
    Have you added the mentioned rules:

    # BEGIN W3TC Minify cache
    <IfModule mod_mime.c>
        AddType text/css .css_gzip
        AddEncoding gzip .css_gzip
        AddType application/x-javascript .js_gzip
        AddEncoding gzip .js_gzip
    </IfModule>
    <IfModule mod_deflate.c>
        <IfModule mod_setenvif.c>
            SetEnvIfNoCase Request_URI \.css_gzip$ no-gzip
            SetEnvIfNoCase Request_URI \.js_gzip$ no-gzip
        </IfModule>
    </IfModule>
    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType text/css M10713600
        ExpiresByType application/x-javascript M10713600
    </IfModule>
    <IfModule mod_headers.c>
        Header set Vary "Accept-Encoding"
    </IfModule>
    # END W3TC Minify cache
    # BEGIN W3TC Minify core
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /wp-content/cache/minify/
        RewriteCond %{HTTP:Accept-Encoding} gzip
        RewriteRule .* - [E=APPEND_EXT:_gzip]
        RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -F
        RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]
        RewriteRule ^(.+\.(css|js))$ /index.php [L]
    </IfModule>
    # END W3TC Minify core

    To the .htaccess file in the root folder of your website or in the /cache/minify/.htaccess?
    If the rules are in the core .htaccess file, have you tried removing those rules and let Browser cache mod_deflare take care of gzip compression of your static JS and CSS files?
    Thank you!

    Thread Starter Mentik Yusmantara

    (@mentikyusmantara)

    I make custom folder in wp-content, for example regarding my post
    /wp-contents/script/gzip/.htaccess (i am copied from /cache/minify/.htaccess) for more than 7 month.
    In that folder i create my custom minified js/css with pre-compressed gzip. Like W3TC plugin work, for example,

    /wp-contents/script/gzip/my-script.js
    /wp-contents/script/gzip/my-script.js_gzip

    every script i create manual gzip with 7z, When using cPanel work correctly and no error log

    Then i am move to unmanaged VPS with directadmin
    The problem was coming, looking for everyone issue, is cause by .htaccess malconfig.

    I looking for updated script .htaccess from w3tc plugin, i think still same as 7 months ago.
    then I searching solution in the internet, meet Mattias Greniad script. Then i fix it by using his script

    /wp-contents/script/gzip/.htaccess
    /wp-contents/script/gzip/my-script.js
    /wp-contents/script/gzip/my-script.js.gz

    No error log in Apache 2.4
    I think .htaccess in standar cache minify w3tc not works correctly in specific server management software, like Directadmin ….

    Cause ur plugin help me a lot of site optimization, so i think is good to inform you about that
    Sorry if the issue is out of the box or maybe my opinion about W3TC minified .htaccess compatibility not right

    Thanks

    Thread Starter Mentik Yusmantara

    (@mentikyusmantara)

    I test the script work because
    when gzip served by php is more bigger in kb
    when gzip served by pre-compiled is more smaller in kb (i create gz with ultra setting with 7z software)

    thanks

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @mentikyusmantara

    Thank you for the information.
    As this was a custom solution previously, it’s not directly related to W3 Total Cache.
    However, thank you for providing details an the solution. WE’ll make sure to investigate this and see if there is a need for implementation in W3 Total Cache.
    Thank you once again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Optimize .HTACCESS for Minified Script AH00125 AH00121 Apache Debug Mode’ is closed to new replies.