• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

NGINX does not GZIP scripts with version parameters

Xavier1234

New Pleskian
Hi,

I'm using latest plesk with ubuntu 12.04, apache and nginx, gzip is enabled and working fine, except for JS and CSS files wich have version parameters in the URI, for example :
http://domain.com/wp-content/plugins/sitepress-multilingual-cms/res/css/language-selector.css?v=3.1.9.7

here is my conf in /etc/nginx/conf.d/gzip.conf :
Code:
gzip         on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_types   text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary    on;

Gzip is working fine for every other ressources loaded
I know i can strip these ?ver= using PHP, but if nginx could just enqueue them properly as they are, i would be the happiest man, thank you!

Thank you
 
Hi Xavier1234,

how do you check, if "...v=3.1.9.7" is being compressed or not? As a matter of fact, the additional string should not be a reason for nginx to not compress such files. Please make sure, that apache AND nginx have the same corresponding gzip - settings.
 
Hi Xavier1234,

how do you check, if "...v=3.1.9.7" is being compressed or not?
Hello and thank you, i check using http://gtmetrix.com/ gtmetrics tells me that all files ending with a parameter ?v=x.x.x or ?ver=x.x.x are not compressed, if i strip the parameter using php, they end up being compressed
Please make sure, that apache AND nginx have the same corresponding gzip - settings.
Apache:
Code:
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
    SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
</IfModule>
and
here is my conf in /etc/nginx/conf.d/gzip.conf :
Code:
gzip         on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_types   text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary    on;
 
Hi Xavier1234,

if you use wordpress, you might wish to use the additional code in your theme - specific - functions.php:

Code:
        function _remove_script_version( $src ){
            $parts = explode( '?', $src );
            return $parts[0];
        }
        add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
        add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
 
Back
Top